Search in sources :

Example 1 with Storage

use of io.trino.plugin.hive.metastore.Storage in project trino by trinodb.

the class TestProtoUtils method testTable.

@Test
public void testTable() {
    alluxio.grpc.table.TableInfo.Builder table = TestingAlluxioMetastoreObjects.getTestingTableInfo();
    alluxio.grpc.table.FieldSchema fieldSchema = TestingAlluxioMetastoreObjects.getTestingFieldSchema().build();
    Table t = ProtoUtils.fromProto(table.build());
    Column c = t.getColumn(TestingAlluxioMetastoreObjects.COLUMN_NAME).get();
    assertEquals(table.getDbName(), t.getDatabaseName());
    assertEquals(table.getTableName(), t.getTableName());
    assertEquals(table.getOwner(), t.getOwner().orElse(null));
    assertEquals(table.getType().toString(), t.getTableType());
    assertEquals(0, t.getDataColumns().size());
    assertEquals(1, t.getPartitionColumns().size());
    assertEquals(table.getParametersMap(), t.getParameters());
    assertEquals(Optional.empty(), t.getViewOriginalText());
    assertEquals(Optional.empty(), t.getViewExpandedText());
    assertEquals(fieldSchema.getName(), c.getName());
    assertEquals(fieldSchema.getComment(), c.getComment().get());
    assertEquals(fieldSchema.getType(), c.getType().toString());
    Storage s = t.getStorage();
    alluxio.grpc.table.layout.hive.Storage storage = TestingAlluxioMetastoreObjects.getTestingPartitionInfo().getStorage();
    assertEquals(storage.getSkewed(), s.isSkewed());
    assertEquals(ProtoUtils.fromProto(storage.getStorageFormat()), s.getStorageFormat());
    assertEquals(storage.getLocation(), s.getLocation());
    assertEquals(ProtoUtils.fromProto(table.getParametersMap(), storage.getBucketProperty()), s.getBucketProperty());
    assertEquals(storage.getStorageFormat().getSerdelibParametersMap(), s.getSerdeParameters());
}
Also used : Table(io.trino.plugin.hive.metastore.Table) Storage(io.trino.plugin.hive.metastore.Storage) Column(io.trino.plugin.hive.metastore.Column) SortingColumn(io.trino.plugin.hive.metastore.SortingColumn) Test(org.testng.annotations.Test)

Example 2 with Storage

use of io.trino.plugin.hive.metastore.Storage in project trino by trinodb.

the class TestProtoUtils method testPartition.

@Test
public void testPartition() {
    alluxio.grpc.table.layout.hive.PartitionInfo.Builder partitionInfo = TestingAlluxioMetastoreObjects.getTestingPartitionInfo();
    Partition partition = ProtoUtils.fromProto(partitionInfo.build());
    assertEquals(partitionInfo.getDataColsList().stream().map(ProtoUtils::fromProto).collect(Collectors.toList()), partition.getColumns());
    assertEquals(partitionInfo.getDbName(), partition.getDatabaseName());
    assertEquals(partitionInfo.getParametersMap(), partition.getParameters());
    assertEquals(partitionInfo.getValuesList(), partition.getValues());
    assertEquals(partitionInfo.getTableName(), partition.getTableName());
    Storage s = partition.getStorage();
    alluxio.grpc.table.layout.hive.Storage storage = TestingAlluxioMetastoreObjects.getTestingPartitionInfo().getStorage();
    assertEquals(storage.getSkewed(), s.isSkewed());
    assertEquals(ProtoUtils.fromProto(storage.getStorageFormat()), s.getStorageFormat());
    assertEquals(storage.getLocation(), s.getLocation());
    assertEquals(ProtoUtils.fromProto(partitionInfo.getParametersMap(), storage.getBucketProperty()), s.getBucketProperty());
    assertEquals(storage.getStorageFormat().getSerdelibParametersMap(), s.getSerdeParameters());
}
Also used : Partition(io.trino.plugin.hive.metastore.Partition) Storage(io.trino.plugin.hive.metastore.Storage) Test(org.testng.annotations.Test)

Example 3 with Storage

use of io.trino.plugin.hive.metastore.Storage in project trino by trinodb.

the class TestDeltaLakeMetastoreStatistics method registerTable.

private DeltaLakeTableHandle registerTable(String tableName, String directoryName) {
    String tableLocation = Resources.getResource("statistics/" + directoryName).toExternalForm();
    Storage tableStorage = new Storage(StorageFormat.create("serde", "input", "output"), Optional.of(tableLocation), Optional.empty(), true, ImmutableMap.of(PATH_PROPERTY, tableLocation));
    hiveMetastore.createTable(new Table("db_name", tableName, Optional.of("test"), "EXTERNAL_TABLE", tableStorage, ImmutableList.of(new Column("val", HiveType.HIVE_DOUBLE, Optional.empty())), ImmutableList.of(), ImmutableMap.of(TABLE_PROVIDER_PROPERTY, TABLE_PROVIDER_VALUE), Optional.empty(), Optional.empty(), OptionalLong.empty()), PrincipalPrivileges.fromHivePrivilegeInfos(ImmutableSet.of()));
    return new DeltaLakeTableHandle("db_name", tableName, "location", Optional.of(new MetadataEntry("id", "test", "description", null, "", ImmutableList.of(), ImmutableMap.of(), 0)), TupleDomain.all(), TupleDomain.all(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), 0);
}
Also used : Storage(io.trino.plugin.hive.metastore.Storage) Table(io.trino.plugin.hive.metastore.Table) Column(io.trino.plugin.hive.metastore.Column) MetadataEntry(io.trino.plugin.deltalake.transactionlog.MetadataEntry) DeltaLakeTableHandle(io.trino.plugin.deltalake.DeltaLakeTableHandle)

Example 4 with Storage

use of io.trino.plugin.hive.metastore.Storage in project trino by trinodb.

the class TestGlueToTrinoConverter method testPartitionConversionMemoization.

@Test
public void testPartitionConversionMemoization() {
    String fakeS3Location = "s3://some-fake-location";
    testPartition.getStorageDescriptor().setLocation(fakeS3Location);
    // Second partition to convert with equal (but not aliased) values
    Partition partitionTwo = getGlueTestPartition("" + testDatabase.getName(), "" + testTable.getName(), new ArrayList<>(testPartition.getValues()));
    // Ensure storage fields match as well
    partitionTwo.getStorageDescriptor().setColumns(new ArrayList<>(testPartition.getStorageDescriptor().getColumns()));
    partitionTwo.getStorageDescriptor().setBucketColumns(new ArrayList<>(testPartition.getStorageDescriptor().getBucketColumns()));
    partitionTwo.getStorageDescriptor().setLocation("" + fakeS3Location);
    partitionTwo.getStorageDescriptor().setInputFormat("" + testPartition.getStorageDescriptor().getInputFormat());
    partitionTwo.getStorageDescriptor().setOutputFormat("" + testPartition.getStorageDescriptor().getOutputFormat());
    partitionTwo.getStorageDescriptor().setParameters(new HashMap<>(testPartition.getStorageDescriptor().getParameters()));
    GluePartitionConverter converter = createPartitionConverter(testTable);
    io.trino.plugin.hive.metastore.Partition trinoPartition = converter.apply(testPartition);
    io.trino.plugin.hive.metastore.Partition trinoPartition2 = converter.apply(partitionTwo);
    assertNotSame(trinoPartition, trinoPartition2);
    assertSame(trinoPartition2.getDatabaseName(), trinoPartition.getDatabaseName());
    assertSame(trinoPartition2.getTableName(), trinoPartition.getTableName());
    assertSame(trinoPartition2.getColumns(), trinoPartition.getColumns());
    assertSame(trinoPartition2.getParameters(), trinoPartition.getParameters());
    assertNotSame(trinoPartition2.getValues(), trinoPartition.getValues());
    Storage storage = trinoPartition.getStorage();
    Storage storage2 = trinoPartition2.getStorage();
    assertSame(storage2.getStorageFormat(), storage.getStorageFormat());
    assertSame(storage2.getBucketProperty(), storage.getBucketProperty());
    assertSame(storage2.getSerdeParameters(), storage.getSerdeParameters());
    assertNotSame(storage2.getLocation(), storage.getLocation());
}
Also used : Partition(com.amazonaws.services.glue.model.Partition) TestingMetastoreObjects.getGlueTestPartition(io.trino.plugin.hive.metastore.glue.TestingMetastoreObjects.getGlueTestPartition) Storage(io.trino.plugin.hive.metastore.Storage) GluePartitionConverter(io.trino.plugin.hive.metastore.glue.converter.GlueToTrinoConverter.GluePartitionConverter) Test(org.testng.annotations.Test)

Aggregations

Storage (io.trino.plugin.hive.metastore.Storage)4 Test (org.testng.annotations.Test)3 Column (io.trino.plugin.hive.metastore.Column)2 Table (io.trino.plugin.hive.metastore.Table)2 Partition (com.amazonaws.services.glue.model.Partition)1 DeltaLakeTableHandle (io.trino.plugin.deltalake.DeltaLakeTableHandle)1 MetadataEntry (io.trino.plugin.deltalake.transactionlog.MetadataEntry)1 Partition (io.trino.plugin.hive.metastore.Partition)1 SortingColumn (io.trino.plugin.hive.metastore.SortingColumn)1 TestingMetastoreObjects.getGlueTestPartition (io.trino.plugin.hive.metastore.glue.TestingMetastoreObjects.getGlueTestPartition)1 GluePartitionConverter (io.trino.plugin.hive.metastore.glue.converter.GlueToTrinoConverter.GluePartitionConverter)1