Search in sources :

Example 1 with HiveColumnConverter

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);
}
Also used : ColumnMetadata(com.facebook.presto.spi.ColumnMetadata) Table(com.facebook.presto.hive.metastore.Table) Storage(com.facebook.presto.hive.metastore.Storage) HiveMetadata.decodePreferredOrderingColumnsFromStorage(com.facebook.presto.hive.HiveMetadata.decodePreferredOrderingColumnsFromStorage) Column(com.facebook.presto.hive.metastore.Column) SortingColumn(com.facebook.presto.hive.metastore.SortingColumn) TestingTypeManager(com.facebook.presto.common.type.TestingTypeManager) TypeManager(com.facebook.presto.common.type.TypeManager) HiveColumnConverter(com.facebook.presto.hive.metastore.HiveColumnConverter) TestingTypeManager(com.facebook.presto.common.type.TestingTypeManager) Test(org.testng.annotations.Test)

Aggregations

TestingTypeManager (com.facebook.presto.common.type.TestingTypeManager)1 TypeManager (com.facebook.presto.common.type.TypeManager)1 HiveMetadata.decodePreferredOrderingColumnsFromStorage (com.facebook.presto.hive.HiveMetadata.decodePreferredOrderingColumnsFromStorage)1 Column (com.facebook.presto.hive.metastore.Column)1 HiveColumnConverter (com.facebook.presto.hive.metastore.HiveColumnConverter)1 SortingColumn (com.facebook.presto.hive.metastore.SortingColumn)1 Storage (com.facebook.presto.hive.metastore.Storage)1 Table (com.facebook.presto.hive.metastore.Table)1 ColumnMetadata (com.facebook.presto.spi.ColumnMetadata)1 Test (org.testng.annotations.Test)1