use of org.apache.iceberg.CachingCatalog in project hive by apache.
the class TestHiveCatalog method testCreateTableWithCaching.
@Test
public void testCreateTableWithCaching() throws Exception {
Schema schema = new Schema(required(1, "id", Types.IntegerType.get(), "unique ID"), required(2, "data", Types.StringType.get()));
PartitionSpec spec = PartitionSpec.builderFor(schema).bucket("data", 16).build();
TableIdentifier tableIdent = TableIdentifier.of(DB_NAME, "tbl");
String location = temp.newFolder("tbl").toString();
ImmutableMap<String, String> properties = ImmutableMap.of("key1", "value1", "key2", "value2");
Catalog cachingCatalog = CachingCatalog.wrap(catalog);
try {
Table table = cachingCatalog.createTable(tableIdent, schema, spec, location, properties);
Assert.assertEquals(location, table.location());
Assert.assertEquals(2, table.schema().columns().size());
Assert.assertEquals(1, table.spec().fields().size());
Assert.assertEquals("value1", table.properties().get("key1"));
Assert.assertEquals("value2", table.properties().get("key2"));
} finally {
cachingCatalog.dropTable(tableIdent);
}
}
Aggregations