Skip to content

Commit f15df0a

Browse files
committed
Use raw metastore table in Delta getTableHandle
This is preparatory change for the next commit that stores the table definition to metastore.
1 parent 3358272 commit f15df0a

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

plugin/trino-delta-lake/src/main/java/io/trino/plugin/deltalake/DeltaLakeMetadata.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,7 @@
230230
import static io.trino.plugin.deltalake.DeltaLakeTableProperties.getPartitionedBy;
231231
import static io.trino.plugin.deltalake.metastore.HiveMetastoreBackedDeltaLakeMetastore.TABLE_PROVIDER_PROPERTY;
232232
import static io.trino.plugin.deltalake.metastore.HiveMetastoreBackedDeltaLakeMetastore.TABLE_PROVIDER_VALUE;
233+
import static io.trino.plugin.deltalake.metastore.HiveMetastoreBackedDeltaLakeMetastore.convertToDeltaMetastoreTable;
233234
import static io.trino.plugin.deltalake.procedure.DeltaLakeTableProcedureId.OPTIMIZE;
234235
import static io.trino.plugin.deltalake.transactionlog.DeltaLakeSchemaSupport.APPEND_ONLY_CONFIGURATION_KEY;
235236
import static io.trino.plugin.deltalake.transactionlog.DeltaLakeSchemaSupport.COLUMN_MAPPING_PHYSICAL_NAME_CONFIGURATION_KEY;
@@ -576,13 +577,14 @@ public LocatedTableHandle getTableHandle(
576577
// Pretend the table does not exist to produce better error message in case of table redirects to Hive
577578
return null;
578579
}
579-
Optional<DeltaMetastoreTable> table = metastore.getTable(tableName.getSchemaName(), tableName.getTableName());
580-
if (table.isEmpty()) {
580+
Optional<Table> metastoreTable = metastore.getRawMetastoreTable(tableName.getSchemaName(), tableName.getTableName());
581+
if (metastoreTable.isEmpty()) {
581582
return null;
582583
}
583-
boolean managed = table.get().managed();
584+
DeltaMetastoreTable table = convertToDeltaMetastoreTable(metastoreTable.get());
585+
boolean managed = table.managed();
584586

585-
String tableLocation = table.get().location();
587+
String tableLocation = table.location();
586588
TrinoFileSystem fileSystem = fileSystemFactory.create(session);
587589
TableSnapshot tableSnapshot = getSnapshot(session, tableName, tableLocation, endVersion.map(version -> getVersion(fileSystem, tableLocation, version)));
588590

0 commit comments

Comments
 (0)