Skip to content

Commit

Permalink
Extract getTableType in GlueConverter
Browse files Browse the repository at this point in the history
  • Loading branch information
pajaks authored and ebyhr committed Feb 4, 2025
1 parent f191bfa commit 5e32f69
Showing 1 changed file with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@
import static io.trino.metastore.Table.TABLE_COMMENT;
import static io.trino.plugin.hive.HiveErrorCode.HIVE_INVALID_METADATA;
import static io.trino.plugin.hive.HiveErrorCode.HIVE_UNSUPPORTED_FORMAT;
import static io.trino.plugin.hive.TableType.EXTERNAL_TABLE;
import static io.trino.plugin.hive.ViewReaderUtil.isTrinoMaterializedView;
import static io.trino.plugin.hive.ViewReaderUtil.isTrinoView;
import static io.trino.plugin.hive.metastore.MetastoreUtil.metastoreFunctionName;
Expand Down Expand Up @@ -119,6 +120,12 @@ final class GlueConverter

private GlueConverter() {}

public static String getTableType(software.amazon.awssdk.services.glue.model.Table glueTable)
{
// Athena treats a missing table type as EXTERNAL_TABLE.
return firstNonNull(getTableTypeNullable(glueTable), EXTERNAL_TABLE.name());
}

@Nullable
@SuppressModernizer // Usage of `Table.tableType` is not allowed. Only this method can call that.
public static String getTableTypeNullable(software.amazon.awssdk.services.glue.model.Table glueTable)
Expand Down Expand Up @@ -149,8 +156,7 @@ public static DatabaseInput toGlueDatabaseInput(Database database)

public static Table fromGlueTable(software.amazon.awssdk.services.glue.model.Table glueTable, String databaseName)
{
// Athena treats a missing table type as EXTERNAL_TABLE.
String tableType = firstNonNull(getTableTypeNullable(glueTable), "EXTERNAL_TABLE");
String tableType = getTableType(glueTable);

Map<String, String> tableParameters = glueTable.parameters();
if (glueTable.description() != null) {
Expand Down

0 comments on commit 5e32f69

Please sign in to comment.