public Table createTestAvroTable(String dbName, String tableName, String tableSdLoc, Optional<String> partitionFieldName, boolean ignoreDbCreation) throws Exception { if (!ignoreDbCreation) { createTestDb(dbName); } Table tbl = org.apache.hadoop.hive.ql.metadata.Table.getEmptyTable(dbName, tableName); tbl.getSd().setLocation(tableSdLoc); tbl.getSd().getSerdeInfo().setSerializationLib(AvroSerDe.class.getName()); tbl.getSd().getSerdeInfo().setParameters(ImmutableMap.of(HiveAvroSerDeManager.SCHEMA_URL, "/tmp/dummy")); if (partitionFieldName.isPresent()) { tbl.addToPartitionKeys(new FieldSchema(partitionFieldName.get(), "string", "some comment")); } this.localMetastoreClient.createTable(tbl); return tbl; }
@Test(expected = InvalidOperationException.class) public void testAlterTableInvalidStorageDescriptorAddPartitionColumns() throws Exception { Table originalTable = testTables[0]; Table newTable = originalTable.deepCopy(); newTable.addToPartitionKeys(new FieldSchema("new_part", "int", "comment")); client.alter_table(originalTable.getDbName(), originalTable.getTableName(), newTable); }
public Table createTestAvroTable(String dbName, String tableName, String tableSdLoc, List<String> partitionFieldNames, boolean ignoreDbCreation) throws Exception { if (!ignoreDbCreation) { createTestDb(dbName); } Table tbl = org.apache.hadoop.hive.ql.metadata.Table.getEmptyTable(dbName, tableName); tbl.getSd().setLocation(tableSdLoc); tbl.getSd().getSerdeInfo().setParameters(ImmutableMap.of(HiveAvroSerDeManager.SCHEMA_URL, "/tmp/dummy")); for (String partitionFieldName : partitionFieldNames) { tbl.addToPartitionKeys(new FieldSchema(partitionFieldName, "string", "some comment")); } this.localMetastoreClient.createTable(tbl); return tbl; }