Refine search
private Scenario scenarioType(org.apache.hadoop.hive.metastore.api.Table before, org.apache.hadoop.hive.metastore.api.Table after) { if (before.getDbName().equals(after.getDbName()) && before.getTableName().equals(after.getTableName())) { return isTruncateOp ? Scenario.TRUNCATE : Scenario.ALTER; } else { return Scenario.RENAME; } }
public T onTable(Table table) { this.catName = table.getCatName(); this.dbName = table.getDbName(); this.tableName = table.getTableName(); return child; }
public HiveObjectRef buildPartitionColumnReference(Table table, String columnName, List<String> partValues) { return new HiveObjectRef(HiveObjectType.COLUMN, table.getDbName(), table.getTableName(), partValues, columnName); } }
public JSONCreateTableMessage(String server, String servicePrincipal, Table tableObj, Iterator<String> fileIter, Long timestamp) { this(server, servicePrincipal, tableObj.getDbName(), tableObj.getTableName(), tableObj.getTableType(), timestamp); try { this.tableObjJson = MessageBuilder.createTableObjJson(tableObj); } catch (TException e) { throw new IllegalArgumentException("Could not serialize: ", e); } this.files = (fileIter != null) ? Lists.newArrayList(fileIter) : Lists.newArrayList(); }
/** * Get table name in cat.db.table format. * @param table table object * @return fully qualified name. */ public static String getCatalogQualifiedTableName(Table table) { return TableName.getQualified(table.getCatName(), table.getDbName(), table.getTableName()); }
private static void removeTempTable(org.apache.hadoop.hive.metastore.api.Table t) { String qualifiedTableName = Warehouse. getQualifiedName(t.getDbName().toLowerCase(), t.getTableName().toLowerCase()); SessionState ss = SessionState.get(); if (ss == null) { LOG.warn("No current SessionState, skipping temp partitions for " + qualifiedTableName); return; } ss.getTempPartitions().remove(Warehouse.getQualifiedName(t)); } private static void createTempTable(org.apache.hadoop.hive.metastore.api.Table t) {
@Override public CreateTableMessage buildCreateTableMessage(Table table) { return new JSONCreateTableMessage(HCAT_SERVER_URL, HCAT_SERVICE_PRINCIPAL, table.getDbName(), table.getTableName(), table.getTableType(), now()); }
@Override public DropTableMessage buildDropTableMessage(Table table) { return new JSONDropTableMessage(HCAT_SERVER_URL, HCAT_SERVICE_PRINCIPAL, table.getDbName(), table.getTableName(), table.getTableType(), now()); }
@Override public InsertMessage buildInsertMessage(String db, Table table, Map<String,String> partKeyVals, List<String> files) { return new JSONInsertMessage(HCAT_SERVER_URL, HCAT_SERVICE_PRINCIPAL, table.getDbName(), table.getTableName(), table.getTableType(), partKeyVals, files, now()); }
@Test(expected = MetaException.class) public void testExchangePartitionsNonExistingValuesInPartSpec() throws Exception { Map<String, String> partitionSpecs = new HashMap<>(); partitionSpecs.put("ev", "2017"); partitionSpecs.put("honap", "march"); partitionSpecs.put("nap", "22"); client.exchange_partitions(partitionSpecs, sourceTable.getDbName(), sourceTable.getTableName(), destTable.getDbName(), destTable.getTableName()); }
@Override public DropPartitionMessage buildDropPartitionMessage(Table table, Iterator<Partition> partitions) { return new JSONDropPartitionMessage(HCAT_SERVER_URL, HCAT_SERVICE_PRINCIPAL, table.getDbName(), table.getTableName(), table.getTableType(), MessageBuilder.getPartitionKeyValues(table, partitions), now()); }
@Override public AddPartitionMessage buildAddPartitionMessage(Table table, Iterator<Partition> partitionsIterator) { return new JSONAddPartitionMessage(HCAT_SERVER_URL, HCAT_SERVICE_PRINCIPAL, table.getDbName(), table.getTableName(), table.getTableType(), MessageBuilder.getPartitionKeyValues(table, partitionsIterator), now()); }
@Test public void testExchangePartitionsDifferentValuesInPartSpec() throws Exception { Map<String, String> partitionSpecs = new HashMap<>(); partitionSpecs.put(YEAR_COL_NAME, "2017"); partitionSpecs.put("honap", "march"); partitionSpecs.put("nap", "22"); client.exchange_partitions(partitionSpecs, sourceTable.getDbName(), sourceTable.getTableName(), destTable.getDbName(), destTable.getTableName()); checkExchangedPartitions(sourceTable, destTable, Lists.newArrayList(partitions[0], partitions[1], partitions[2], partitions[3])); checkRemainingPartitions(sourceTable, destTable, Lists.newArrayList(partitions[4])); }
@Test public void testExchangePartitionDifferentValuesInPartSpec() throws Exception { Map<String, String> partitionSpecs = new HashMap<>(); partitionSpecs.put(YEAR_COL_NAME, "2017"); partitionSpecs.put("honap", "march"); partitionSpecs.put("nap", "22"); client.exchange_partition(partitionSpecs, sourceTable.getDbName(), sourceTable.getTableName(), destTable.getDbName(), destTable.getTableName()); checkExchangedPartitions(sourceTable, destTable, Lists.newArrayList(partitions[0], partitions[1], partitions[2], partitions[3])); checkRemainingPartitions(sourceTable, destTable, Lists.newArrayList(partitions[4])); }
@Test(expected = MetaException.class) public void testAppendPartitionToView() throws Exception { List<String> partitionValues = Lists.newArrayList("2017", "may"); Table table = tableView; client.appendPartition(table.getDbName(), table.getTableName(), partitionValues); }
@Test(expected = AlreadyExistsException.class) public void testAppendPartitionAlreadyExists() throws Exception { List<String> partitionValues = Lists.newArrayList("2017", "april"); Table table = tableWithPartitions; client.appendPartition(table.getDbName(), table.getTableName(), partitionValues); }
@Test(expected = MetaException.class) public void testAppendPartitionEmptyPartValues() throws Exception { Table table = tableWithPartitions; client.appendPartition(table.getDbName(), table.getTableName(), new ArrayList<>()); }
@Test(expected = MetaException.class) public void testAppendPartToTableWithoutPartCols() throws Exception { String partitionName = "year=2017/month=may"; Table table = tableNoPartColumns; client.appendPartition(table.getDbName(), table.getTableName(), partitionName); }
@Test(expected = MetaException.class) public void testAppendPartEmptyPartName() throws Exception { Table table = tableWithPartitions; client.appendPartition(table.getDbName(), table.getTableName(), ""); }
private void verifyPartitionNames(Table table, List<String> expectedPartNames) throws Exception { List<String> partitionNames = client.listPartitionNames(table.getDbName(), table.getTableName(), (short) -1); Assert.assertEquals(expectedPartNames.size(), partitionNames.size()); Assert.assertTrue(partitionNames.containsAll(expectedPartNames)); } }