Skip to content

World's most powerful open data catalog for building a high-performance, geo-distributed and federated metadata lake.

[#2027] fix(trino-connector): Fix the bug that `format` configuration can't overwrite default `InputFormat` value. (#2030)

Qi Yuc60a3c44a531
diff --git a/integration-test/src/test/java/com/datastrato/gravitino/integration/test/trino/TrinoConnectorIT.java b/integration-test/src/test/java/com/datastrato/gravitino/integration/test/trino/TrinoConnectorIT.java
index a54a464143..2c8af6ca51 100644
--- a/integration-test/src/test/java/com/datastrato/gravitino/integration/test/trino/TrinoConnectorIT.java
+++ b/integration-test/src/test/java/com/datastrato/gravitino/integration/test/trino/TrinoConnectorIT.java
@@ -762,6 +762,65 @@ public class TrinoConnectorIT extends AbstractIT {
Assertions.assertTrue(data.contains("bucketed_by = ARRAY['booleantype']"));
Assertions.assertTrue(data.contains("partitioned_by = ARRAY['binarytype']"));
Assertions.assertTrue(data.contains("sorted_by = ARRAY['longtype']"));
+
+ // Test table format issues.
+ tableName = GravitinoITUtils.genRandomName("table_format1").toLowerCase();
+ sql =
+ String.format(
+ "CREATE TABLE \"%s.%s\".%s.%s (id int, name varchar) with (format = 'ORC')",
+ metalakeName, catalogName, schemaName, tableName);
+ containerSuite.getTrinoContainer().executeUpdateSQL(sql);
+
+ sql =
+ String.format(
+ "show create table \"%s.%s\".%s.%s", metalakeName, catalogName, schemaName, tableName);
+ Assertions.assertTrue(checkTrinoHasLoaded(sql, 30), "Trino fail to create table:" + tableName);
+ data = containerSuite.getTrinoContainer().executeQuerySQL(sql).get(0).get(0);
+
+ Assertions.assertTrue(
+ data.contains("input_format = 'org.apache.hadoop.hive.ql.io.orc.OrcInputFormat'"));
+ Assertions.assertTrue(
+ data.contains("output_format = 'org.apache.hadoop.hive.ql.io.orc.OrcOutputFormat'"));
+ Assertions.assertTrue(data.contains("serde_lib = 'org.apache.hadoop.hive.ql.io.orc.OrcSerde'"));
+
+ // Test input_format can overwrite format setting
+ tableName = GravitinoITUtils.genRandomName("table_format2").toLowerCase();
+ sql =
+ String.format(
+ "CREATE TABLE \"%s.%s\".%s.%s (id int, name varchar) with (format = 'ORC', input_format = 'org.apache.hadoop.mapred.TextInputFormat')",
+ metalakeName, catalogName, schemaName, tableName);
+ containerSuite.getTrinoContainer().executeUpdateSQL(sql);
+ sql =
+ String.format(
+ "show create table \"%s.%s\".%s.%s", metalakeName, catalogName, schemaName, tableName);
+ Assertions.assertTrue(checkTrinoHasLoaded(sql, 30), "Trino fail to create table:" + tableName);
+ data = containerSuite.getTrinoContainer().executeQuerySQL(sql).get(0).get(0);
+
+ Assertions.assertTrue(
+ data.contains("input_format = 'org.apache.hadoop.mapred.TextInputFormat'"));
+ Assertions.assertTrue(
+ data.contains("output_format = 'org.apache.hadoop.hive.ql.io.orc.OrcOutputFormat'"));
+ Assertions.assertTrue(data.contains("serde_lib = 'org.apache.hadoop.hive.ql.io.orc.OrcSerde'"));
+
+ // Test output_format can overwrite format setting
+ tableName = GravitinoITUtils.genRandomName("table_format3").toLowerCase();
+ sql =
+ String.format(
+ "CREATE TABLE \"%s.%s\".%s.%s (id int, name varchar) with (format = 'ORC', output_format = 'org.apache.hadoop.hive.ql.io.HiveIgnoreKeyTextOutputFormat')",
+ metalakeName, catalogName, schemaName, tableName);
+ containerSuite.getTrinoContainer().executeUpdateSQL(sql);
+ sql =
+ String.format(
+ "show create table \"%s.%s\".%s.%s", metalakeName, catalogName, schemaName, tableName);
+ Assertions.assertTrue(checkTrinoHasLoaded(sql, 30), "Trino fail to create table:" + tableName);
+ data = containerSuite.getTrinoContainer().executeQuerySQL(sql).get(0).get(0);
+
+ Assertions.assertTrue(
+ data.contains("input_format = 'org.apache.hadoop.hive.ql.io.orc.OrcInputFormat'"));
+ Assertions.assertTrue(
+ data.contains(
+ "output_format = 'org.apache.hadoop.hive.ql.io.HiveIgnoreKeyTextOutputFormat'"));
+ Assertions.assertTrue(data.contains("serde_lib = 'org.apache.hadoop.hive.ql.io.orc.OrcSerde'"));
}
@Test
diff --git a/trino-connector/src/main/java/com/datastrato/gravitino/trino/connector/catalog/hive/HivePropertyMeta.java b/trino-connector/src/main/java/com/datastrato/gravitino/trino/connector/catalog/hive/HivePropertyMeta.java
index e1fa07a2d0..d788634725 100644
--- a/trino-connector/src/main/java/com/datastrato/gravitino/trino/connector/catalog/hive/HivePropertyMeta.java
+++ b/trino-connector/src/main/java/com/datastrato/gravitino/trino/connector/catalog/hive/HivePropertyMeta.java
@@ -54,20 +54,11 @@ public class HivePropertyMeta implements HasPropertyMeta {
stringProperty(HIVE_TABLE_LOCATION, "HDFS location for table storage", null, false),
stringProperty(HIVE_TABLE_TYPE, "The type of Hive table", null, false),
stringProperty(
- HIVE_TABLE_INPUT_FORMAT,
- "The input format class for the table",
- "org.apache.hadoop.mapred.TextInputFormat",
- false),
+ HIVE_TABLE_INPUT_FORMAT, "The input format class for the table", null, false),
stringProperty(
- HIVE_TABLE_OUTPUT_FORMAT,
- "The output format class for the table",
- "org.apache.hadoop.hive.ql.io.HiveIgnoreKeyTextOutputFormat",
- false),
+ HIVE_TABLE_OUTPUT_FORMAT, "The output format class for the table", null, false),
stringProperty(
- HIVE_TABLE_SERDE_LIB,
- "The serde library class for the table",
- "org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe",
- false),
+ HIVE_TABLE_SERDE_LIB, "The serde library class for the table", null, false),
stringProperty(
HIVE_TABLE_SERDE_NAME, "Name of the serde, table name by default", null, false),
new PropertyMetadata<>(