Skip to content

Commit

Permalink
Fix reading Delta Table metadata from Glue
Browse files Browse the repository at this point in the history
Cherry-pick of trinodb/trino#12164

Delta Lake connector expects that the metastore storage descriptor be
fully translated if it exists. It only needs to return a dummy storage
value if no storage descriptor has been configured.

Co-authored-by: Eric Hwang <eric.hwang@starburstdata.com>
  • Loading branch information
v-jizhang and erichwang committed May 17, 2022
1 parent 8c8cfe4 commit 09edabe
Showing 1 changed file with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -83,15 +83,15 @@ public static Table convertTable(com.amazonaws.services.glue.model.Table glueTab
.setViewOriginalText(Optional.ofNullable(glueTable.getViewOriginalText()))
.setViewExpandedText(Optional.ofNullable(glueTable.getViewExpandedText()));

if (isIcebergTable(tableParameters) || isDeltaLakeTable(tableParameters)) {
StorageDescriptor sd = glueTable.getStorageDescriptor();
if (isIcebergTable(tableParameters) || (sd == null && isDeltaLakeTable(tableParameters))) {
// Iceberg and Delta Lake tables do not use the StorageDescriptor field, but we need to return a Table so the caller can check that
// the table is an Iceberg/Delta table and decide whether to redirect or fail.
tableBuilder.setDataColumns(ImmutableList.of(new Column("dummy", HIVE_INT, Optional.empty(), Optional.empty())));
tableBuilder.getStorageBuilder().setStorageFormat(StorageFormat.fromHiveStorageFormat(HiveStorageFormat.PARQUET));
tableBuilder.getStorageBuilder().setLocation(sd.getLocation());
}
else {
StorageDescriptor sd = glueTable.getStorageDescriptor();
if (sd == null) {
throw new PrestoException(HIVE_UNSUPPORTED_FORMAT, format("Table StorageDescriptor is null for table %s.%s (%s)", dbName, glueTable.getName(), glueTable));
}
Expand Down

0 comments on commit 09edabe

Please sign in to comment.