use of com.facebook.presto.hive.metastore.HiveColumnConverter in project presto by prestodb.
the class TestHiveMetadata method testColumnMetadataGetter.
@Test
public void testColumnMetadataGetter() {
TypeManager mockTypeManager = new TestingTypeManager();
Column column1 = new Column("c1", HIVE_INT, Optional.empty(), Optional.of("some-metadata"));
HiveColumnHandle hiveColumnHandle1 = new HiveColumnHandle(column1.getName(), HiveType.HIVE_INT, TypeSignature.parseTypeSignature("int"), 0, HiveColumnHandle.ColumnType.REGULAR, Optional.empty(), Optional.empty());
HiveColumnHandle hidden = new HiveColumnHandle(HiveColumnHandle.PATH_COLUMN_NAME, HiveType.HIVE_INT, TypeSignature.parseTypeSignature("int"), 0, HiveColumnHandle.ColumnType.SYNTHESIZED, Optional.empty(), Optional.empty());
Column partitionColumn = new Column("ds", HIVE_STRING, Optional.empty(), Optional.empty());
Table mockTable = new Table("schema", "table", "user", PrestoTableType.MANAGED_TABLE, new Storage(fromHiveStorageFormat(ORC), "location", Optional.of(new HiveBucketProperty(ImmutableList.of(column1.getName()), 100, ImmutableList.of(), HIVE_COMPATIBLE, Optional.empty())), false, ImmutableMap.of(), ImmutableMap.of()), ImmutableList.of(column1), ImmutableList.of(partitionColumn), ImmutableMap.of(), Optional.empty(), Optional.empty());
ColumnMetadata actual = HiveMetadata.columnMetadataGetter(mockTable, mockTypeManager, new HiveColumnConverter()).apply(hiveColumnHandle1);
ColumnMetadata expected = new ColumnMetadata("c1", IntegerType.INTEGER);
assertEquals(actual, expected);
actual = HiveMetadata.columnMetadataGetter(mockTable, mockTypeManager, new TestColumnConverter()).apply(hidden);
expected = ColumnMetadata.builder().setName(HiveColumnHandle.PATH_COLUMN_NAME).setType(IntegerType.INTEGER).setHidden(true).build();
assertEquals(actual, expected);
}
Aggregations