Skip to content

Commit e7d850c

Browse files
committed
Extract a method to convert metastore table
1 parent 1d5884d commit e7d850c

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

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

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -74,13 +74,8 @@ public Optional<Table> getRawMetastoreTable(String databaseName, String tableNam
7474
@Override
7575
public Optional<DeltaMetastoreTable> getTable(String databaseName, String tableName)
7676
{
77-
return getRawMetastoreTable(databaseName, tableName).map(table -> {
78-
verifyDeltaLakeTable(table);
79-
return new DeltaMetastoreTable(
80-
new SchemaTableName(databaseName, tableName),
81-
table.getTableType().equals(MANAGED_TABLE.name()),
82-
getTableLocation(table));
83-
});
77+
return getRawMetastoreTable(databaseName, tableName)
78+
.map(HiveMetastoreBackedDeltaLakeMetastore::convertToDeltaMetastoreTable);
8479
}
8580

8681
public static void verifyDeltaLakeTable(Table table)
@@ -130,6 +125,15 @@ public void renameTable(SchemaTableName from, SchemaTableName to)
130125
delegate.renameTable(from.getSchemaName(), from.getTableName(), to.getSchemaName(), to.getTableName());
131126
}
132127

128+
public static DeltaMetastoreTable convertToDeltaMetastoreTable(Table table)
129+
{
130+
verifyDeltaLakeTable(table);
131+
return new DeltaMetastoreTable(
132+
new SchemaTableName(table.getDatabaseName(), table.getTableName()),
133+
table.getTableType().equals(MANAGED_TABLE.name()),
134+
getTableLocation(table));
135+
}
136+
133137
public static String getTableLocation(Table table)
134138
{
135139
Map<String, String> serdeParameters = table.getStorage().getSerdeParameters();

0 commit comments

Comments
 (0)