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());
}
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());
}
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);
}
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());
}
Aggregations