/** * * @param db name of the database the table is in * @param table name of the table being inserted into * @param partVals list of partition values, can be null * @param status status of insert, true = success, false = failure * @param handler handler that is firing the event */ public InsertEvent(String db, String table, List<String> partVals, List<String> files, boolean status, HMSHandler handler) throws MetaException, NoSuchObjectException { super(status, handler); this.db = db; this.table = table; this.files = files; Table t = handler.get_table(db,table); keyValues = new LinkedHashMap<String, String>(); if (partVals != null) { for (int i = 0; i < partVals.size(); i++) { keyValues.put(t.getPartitionKeys().get(i).getName(), partVals.get(i)); } } }
/** * * @param db name of the database the table is in * @param table name of the table being inserted into * @param partVals list of partition values, can be null * @param status status of insert, true = success, false = failure * @param handler handler that is firing the event */ public InsertEvent(String db, String table, List<String> partVals, List<String> files, boolean status, HMSHandler handler) throws MetaException, NoSuchObjectException { super(status, handler); this.db = db; this.table = table; this.files = files; Table t = handler.get_table(db,table); keyValues = new LinkedHashMap<String, String>(); if (partVals != null) { for (int i = 0; i < partVals.size(); i++) { keyValues.put(t.getPartitionKeys().get(i).getName(), partVals.get(i)); } } }
Table t; try { t = get_table(db_name, tbl_name); } catch (NoSuchObjectException e) { throw new MetaException(e.getMessage());
String partName = null; if (partValues != null && partValues.size()>0) { Table tbl = get_table(dbName, tableName); partName = Warehouse.makePartName(tbl.getPartitionKeys(), partValues);
Exception ex = null; try { Table oldt = get_table(dbname, name); firePreEvent(new PreAlterTableEvent(oldt, newTable, this)); alterHandler.alterTable(getMS(), wh, dbname, name, newTable);
tbl = get_table(db_name, tbl_name); } finally { if (!success) {
tbl = get_table(db, base_table_name); } catch (NoSuchObjectException e) { throw new UnknownTableException(e.getMessage());
if (idxTblName != null) { Table tbl = null; tbl = this.get_table(dbName, idxTblName); if (tbl.getSd() == null) { throw new MetaException("Table metadata is corrupted");
try { try { tbl = get_table(db, base_table_name); } catch (NoSuchObjectException e) { throw new UnknownTableException(e.getMessage());
String partitionLocation = getSdLocation(partition.getSd()); if (!StringUtils.isEmpty(partitionLocation)) { String tableLocation = context.getHandler().get_table( partition.getDbName(), partition.getTableName()).getSd().getLocation();
event.getHandler().get_table( event.getOldPartition().getDbName(), event.getOldPartition().getTableName()
tbl = get_table(db, base_table_name); } catch (NoSuchObjectException e) { throw new UnknownTableException(e.getMessage());
Table tbl = get_table(dbName, tableName); String partName = Warehouse.makePartName(tbl.getPartitionKeys(), partValues); List<MPartitionPrivilege> mParts = ms.listPrincipalPartitionGrants(
public List<FieldSchema> get_fields(String db, String tableName) throws MetaException, UnknownTableException, UnknownDBException { startFunction("get_fields", ": db=" + db + "tbl=" + tableName); String[] names = tableName.split("\\."); String base_table_name = names[0]; Table tbl; try { try { tbl = get_table(db, base_table_name); } catch (NoSuchObjectException e) { throw new UnknownTableException(e.getMessage()); } boolean getColsFromSerDe = SerDeUtils.shouldGetColsFromSerDe( tbl.getSd().getSerdeInfo().getSerializationLib()); if (!getColsFromSerDe) { return tbl.getSd().getCols(); } else { try { Deserializer s = MetaStoreUtils.getDeserializer(hiveConf, tbl); return MetaStoreUtils.getFieldsFromDeserializer(tableName, s); } catch (SerDeException e) { StringUtils.stringifyException(e); throw new MetaException(e.getMessage()); } } } finally { endFunction("get_fields"); } }
event.getHandler().get_table( event.getOldPartition().getDbName(), event.getOldPartition().getTableName()
String tableLocation = context .getHandler() .get_table(mapiPart.getDbName(), mapiPart.getTableName()).getSd().getLocation(); String uriPath;
@Override List<HiveObjectPrivilege> run(RawStore ms) throws Exception { Table tbl = get_table(dbName, tableName); String partName = Warehouse.makePartName(tbl.getPartitionKeys(), partValues); List<MPartitionPrivilege> mParts = ms.listPrincipalPartitionGrants( principalName, principalType, dbName, tableName, partName); if (mParts.size() > 0) { List<HiveObjectPrivilege> result = new ArrayList<HiveObjectPrivilege>(); for (int i = 0; i < mParts.size(); i++) { MPartitionPrivilege sPart = mParts.get(i); HiveObjectRef objectRef = new HiveObjectRef( HiveObjectType.PARTITION, dbName, tableName, partValues, null); HiveObjectPrivilege secObj = new HiveObjectPrivilege(objectRef, sPart.getPrincipalName(), principalType, new PrivilegeGrantInfo(sPart.getPrivilege(), sPart .getCreateTime(), sPart.getGrantor(), PrincipalType .valueOf(sPart.getGrantorType()), sPart .getGrantOption())); result.add(secObj); } return result; } return null; } });
private void simulatedRenamePartition(String dbName, String tableName, String oldPartitionName, List<String> newPartitionValues) throws Exception { Partition oldPartition = srcMetastore.getPartition(dbName, tableName, oldPartitionName); Partition newPartition = new Partition(oldPartition); newPartition.setValues(newPartitionValues); HiveConf hiveConf = AuditLogHookUtils.getMetastoreHiveConf( embeddedMySqlDb, AUDIT_LOG_DB_NAME, AUDIT_LOG_TABLE_NAME, AUDIT_LOG_OBJECTS_TABLE_NAME ); HiveMetaStore.HMSHandler handler = Mockito.mock(HiveMetaStore.HMSHandler.class); Mockito.when( handler.get_table(dbName, tableName) ).thenReturn(srcMetastore.getTable(dbName, tableName)); AuditLogHookUtils.insertThriftRenamePartitionLogEntry( handler, oldPartition, newPartition, hiveConf ); }
private String getPartName(HiveObjectRef hiveObject) throws MetaException { String partName = null; List<String> partValue = hiveObject.getPartValues(); if (partValue != null && partValue.size() > 0) { try { Table table = get_table(hiveObject.getDbName(), hiveObject .getObjectName()); partName = Warehouse .makePartName(table.getPartitionKeys(), partValue); } catch (NoSuchObjectException e) { throw new MetaException(e.getMessage()); } } return partName; }
private String getPartName(HiveObjectRef hiveObject) throws MetaException { String partName = null; List<String> partValue = hiveObject.getPartValues(); if (partValue != null && partValue.size() > 0) { try { Table table = get_table(hiveObject.getDbName(), hiveObject .getObjectName()); partName = Warehouse .makePartName(table.getPartitionKeys(), partValue); } catch (NoSuchObjectException e) { throw new MetaException(e.getMessage()); } } return partName; }