diff --git a/.mvn/modernizer/violations.xml b/.mvn/modernizer/violations.xml
index 6b4ad47ca408..737bb7d41a22 100644
--- a/.mvn/modernizer/violations.xml
+++ b/.mvn/modernizer/violations.xml
@@ -152,6 +152,24 @@
Table type is nullable in Glue model, which is too easy to forget about. Prefer GlueToTrinoConverter.getTableType
+
+ com/amazonaws/services/glue/model/Table.getParameters:()Ljava/util/Map;
+ 1.1
+ Table parameters map is nullable in Glue model, which is too easy to forget about. Prefer GlueToTrinoConverter.getTableParameters
+
+
+
+ com/amazonaws/services/glue/model/Partition.getParameters:()Ljava/util/Map;
+ 1.1
+ Partition parameters map is nullable in Glue model, which is too easy to forget about. Prefer GlueToTrinoConverter.getPartitionParameters
+
+
+
+ com/amazonaws/services/glue/model/SerDeInfo.getParameters:()Ljava/util/Map;
+ 1.1
+ SerDeInfo parameters map is nullable in Glue model, which is too easy to forget about. Prefer GlueToTrinoConverter.getSerDeInfoParameters
+
+
org/apache/hadoop/mapred/JobConf."<init>":()V
1.1
diff --git a/plugin/trino-hive/src/main/java/io/trino/plugin/hive/ViewReaderUtil.java b/plugin/trino-hive/src/main/java/io/trino/plugin/hive/ViewReaderUtil.java
index 643397f41494..22efedcad546 100644
--- a/plugin/trino-hive/src/main/java/io/trino/plugin/hive/ViewReaderUtil.java
+++ b/plugin/trino-hive/src/main/java/io/trino/plugin/hive/ViewReaderUtil.java
@@ -150,15 +150,22 @@ public static boolean isHiveOrPrestoView(String tableType)
return tableType.equals(VIRTUAL_VIEW.name());
}
+ public static boolean isTrinoMaterializedView(Table table)
+ {
+ return isTrinoMaterializedView(table.getTableType(), table.getParameters());
+ }
+
public static boolean isTrinoMaterializedView(String tableType, Map tableParameters)
{
+ // TODO isHiveOrPrestoView should not return true for materialized views
return isHiveOrPrestoView(tableType) && isPrestoView(tableParameters) && tableParameters.get(TABLE_COMMENT).equalsIgnoreCase(ICEBERG_MATERIALIZED_VIEW_COMMENT);
}
public static boolean canDecodeView(Table table)
{
// we can decode Hive or Presto view
- return table.getTableType().equals(VIRTUAL_VIEW.name());
+ return table.getTableType().equals(VIRTUAL_VIEW.name()) &&
+ !isTrinoMaterializedView(table.getTableType(), table.getParameters());
}
public static String encodeViewData(ConnectorViewDefinition definition)
diff --git a/plugin/trino-hive/src/main/java/io/trino/plugin/hive/metastore/glue/DefaultGlueMetastoreTableFilterProvider.java b/plugin/trino-hive/src/main/java/io/trino/plugin/hive/metastore/glue/DefaultGlueMetastoreTableFilterProvider.java
index 63ef87298ec3..b80a76c23337 100644
--- a/plugin/trino-hive/src/main/java/io/trino/plugin/hive/metastore/glue/DefaultGlueMetastoreTableFilterProvider.java
+++ b/plugin/trino-hive/src/main/java/io/trino/plugin/hive/metastore/glue/DefaultGlueMetastoreTableFilterProvider.java
@@ -22,7 +22,7 @@
import java.util.Map;
import java.util.function.Predicate;
-import static com.google.common.base.MoreObjects.firstNonNull;
+import static io.trino.plugin.hive.metastore.glue.converter.GlueToTrinoConverter.getTableParameters;
import static io.trino.plugin.hive.util.HiveUtil.DELTA_LAKE_PROVIDER;
import static io.trino.plugin.hive.util.HiveUtil.SPARK_TABLE_PROVIDER_KEY;
import static java.util.function.Predicate.not;
@@ -49,7 +49,7 @@ public Predicate get()
public static boolean isDeltaLakeTable(Table table)
{
- Map parameters = firstNonNull(table.getParameters(), Map.of());
+ Map parameters = getTableParameters(table);
return parameters.getOrDefault(SPARK_TABLE_PROVIDER_KEY, "").equalsIgnoreCase(DELTA_LAKE_PROVIDER);
}
}
diff --git a/plugin/trino-hive/src/main/java/io/trino/plugin/hive/metastore/glue/GlueHiveMetastore.java b/plugin/trino-hive/src/main/java/io/trino/plugin/hive/metastore/glue/GlueHiveMetastore.java
index 55b0eeea8a52..84927baacecb 100644
--- a/plugin/trino-hive/src/main/java/io/trino/plugin/hive/metastore/glue/GlueHiveMetastore.java
+++ b/plugin/trino-hive/src/main/java/io/trino/plugin/hive/metastore/glue/GlueHiveMetastore.java
@@ -132,7 +132,6 @@
import java.util.function.Function;
import java.util.function.Predicate;
-import static com.google.common.base.MoreObjects.firstNonNull;
import static com.google.common.base.Strings.isNullOrEmpty;
import static com.google.common.base.Verify.verify;
import static com.google.common.collect.Comparators.lexicographical;
@@ -149,6 +148,7 @@
import static io.trino.plugin.hive.metastore.glue.AwsSdkUtil.getPaginatedResults;
import static io.trino.plugin.hive.metastore.glue.GlueClientUtil.createAsyncGlueClient;
import static io.trino.plugin.hive.metastore.glue.converter.GlueInputConverter.convertPartition;
+import static io.trino.plugin.hive.metastore.glue.converter.GlueToTrinoConverter.getTableParameters;
import static io.trino.plugin.hive.metastore.glue.converter.GlueToTrinoConverter.getTableTypeNullable;
import static io.trino.plugin.hive.metastore.glue.converter.GlueToTrinoConverter.mappedCopy;
import static io.trino.plugin.hive.metastore.thrift.ThriftMetastoreUtil.getHiveBasicStatistics;
@@ -442,7 +442,7 @@ public List getAllTables(String databaseName)
@Override
public synchronized List getTablesWithParameter(String databaseName, String parameterKey, String parameterValue)
{
- return getAllViews(databaseName, table -> parameterValue.equals(firstNonNull(table.getParameters(), ImmutableMap.of()).get(parameterKey)));
+ return getAllViews(databaseName, table -> parameterValue.equals(getTableParameters(table).get(parameterKey)));
}
@Override
@@ -680,7 +680,7 @@ private TableInput convertGlueTableToTableInput(com.amazonaws.services.glue.mode
.withViewExpandedText(glueTable.getViewExpandedText())
.withTableType(getTableTypeNullable(glueTable))
.withTargetTable(glueTable.getTargetTable())
- .withParameters(glueTable.getParameters());
+ .withParameters(getTableParameters(glueTable));
}
@Override
diff --git a/plugin/trino-hive/src/main/java/io/trino/plugin/hive/metastore/glue/converter/GlueToTrinoConverter.java b/plugin/trino-hive/src/main/java/io/trino/plugin/hive/metastore/glue/converter/GlueToTrinoConverter.java
index e6c2307846a7..d880b9483335 100644
--- a/plugin/trino-hive/src/main/java/io/trino/plugin/hive/metastore/glue/converter/GlueToTrinoConverter.java
+++ b/plugin/trino-hive/src/main/java/io/trino/plugin/hive/metastore/glue/converter/GlueToTrinoConverter.java
@@ -51,6 +51,7 @@
import static io.trino.plugin.hive.HiveErrorCode.HIVE_UNSUPPORTED_FORMAT;
import static io.trino.plugin.hive.HiveType.HIVE_INT;
import static io.trino.plugin.hive.TableType.EXTERNAL_TABLE;
+import static io.trino.plugin.hive.ViewReaderUtil.isTrinoMaterializedView;
import static io.trino.plugin.hive.metastore.util.Memoizers.memoizeLast;
import static io.trino.plugin.hive.util.HiveUtil.isDeltaLakeTable;
import static io.trino.plugin.hive.util.HiveUtil.isIcebergTable;
@@ -76,6 +77,24 @@ public static String getTableTypeNullable(com.amazonaws.services.glue.model.Tabl
return glueTable.getTableType();
}
+ @SuppressModernizer // Usage of `Table.getParameters` is not allowed. Only this method can call that.
+ public static Map getTableParameters(com.amazonaws.services.glue.model.Table glueTable)
+ {
+ return firstNonNull(glueTable.getParameters(), ImmutableMap.of());
+ }
+
+ @SuppressModernizer // Usage of `Partition.getParameters` is not allowed. Only this method can call that.
+ public static Map getPartitionParameters(com.amazonaws.services.glue.model.Partition gluePartition)
+ {
+ return firstNonNull(gluePartition.getParameters(), ImmutableMap.of());
+ }
+
+ @SuppressModernizer // Usage of `SerDeInfo.getParameters` is not allowed. Only this method can call that.
+ public static Map getSerDeInfoParameters(com.amazonaws.services.glue.model.SerDeInfo glueSerDeInfo)
+ {
+ return firstNonNull(glueSerDeInfo.getParameters(), ImmutableMap.of());
+ }
+
public static Database convertDatabase(com.amazonaws.services.glue.model.Database glueDb)
{
return Database.builder()
@@ -95,21 +114,25 @@ public static Table convertTable(com.amazonaws.services.glue.model.Table glueTab
{
SchemaTableName table = new SchemaTableName(dbName, glueTable.getName());
- Map tableParameters = convertParameters(glueTable.getParameters());
+ String tableType = getTableType(glueTable);
+ Map tableParameters = ImmutableMap.copyOf(getTableParameters(glueTable));
Table.Builder tableBuilder = Table.builder()
.setDatabaseName(table.getSchemaName())
.setTableName(table.getTableName())
.setOwner(Optional.ofNullable(glueTable.getOwner()))
- .setTableType(getTableType(glueTable))
+ .setTableType(tableType)
.setParameters(tableParameters)
.setViewOriginalText(Optional.ofNullable(glueTable.getViewOriginalText()))
.setViewExpandedText(Optional.ofNullable(glueTable.getViewExpandedText()));
StorageDescriptor sd = glueTable.getStorageDescriptor();
- if (isIcebergTable(tableParameters) || (sd == null && isDeltaLakeTable(tableParameters))) {
+ if (isIcebergTable(tableParameters) ||
+ (sd == null && isDeltaLakeTable(tableParameters)) ||
+ (sd == null && isTrinoMaterializedView(tableType, tableParameters))) {
// Iceberg tables do not need to read the StorageDescriptor field, but we still need to return dummy properties for compatibility
// Delta Lake tables only need to provide a dummy properties if a StorageDescriptor was not explicitly configured.
+ // Materialized views do not need to read the StorageDescriptor, but we still need to return dummy properties for compatibility
tableBuilder.setDataColumns(ImmutableList.of(new Column("dummy", HIVE_INT, Optional.empty())));
tableBuilder.getStorageBuilder().setStorageFormat(StorageFormat.fromHiveStorageFormat(HiveStorageFormat.PARQUET));
}
@@ -157,17 +180,9 @@ private static List convertColumns(SchemaTableName table, List convertColumn(table, glueColumn, serde));
}
- private static Map convertParameters(Map parameters)
- {
- if (parameters == null || parameters.isEmpty()) {
- return ImmutableMap.of();
- }
- return ImmutableMap.copyOf(parameters);
- }
-
private static Function