This is an automated email from the ASF dual-hosted git repository.
dkuzmenko pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/hive.git
The following commit(s) were added to refs/heads/master by this push:
new 6d45a6db865 HIVE-28154: Throw friendly exception if the table does not
support partition transform (Butao Zhang, reviewed by Denys Kuzmenko, Shohei
Okumiya)
6d45a6db865 is described below
commit 6d45a6db8652b75843b94d96432533b991c99e23
Author: Butao Zhang <[email protected]>
AuthorDate: Thu Apr 11 22:45:57 2024 +0800
HIVE-28154: Throw friendly exception if the table does not support
partition transform (Butao Zhang, reviewed by Denys Kuzmenko, Shohei Okumiya)
Closes #5166
---
common/src/java/org/apache/hadoop/hive/ql/ErrorMsg.java | 1 +
.../iceberg/mr/hive/TestHiveIcebergStorageHandlerNoScan.java | 10 ++++++++++
.../java/org/apache/hadoop/hive/ql/parse/SemanticAnalyzer.java | 2 ++
3 files changed, 13 insertions(+)
diff --git a/common/src/java/org/apache/hadoop/hive/ql/ErrorMsg.java
b/common/src/java/org/apache/hadoop/hive/ql/ErrorMsg.java
index 4d94e6dae5a..5503e4e01c9 100644
--- a/common/src/java/org/apache/hadoop/hive/ql/ErrorMsg.java
+++ b/common/src/java/org/apache/hadoop/hive/ql/ErrorMsg.java
@@ -486,6 +486,7 @@ public enum ErrorMsg {
NON_NATIVE_ACID_UPDATE(10435, "Update and Merge to a non-native ACID table
in \"merge-on-read\" mode is only supported when \"" +
HiveConf.ConfVars.SPLIT_UPDATE.varname + "\"=\"true\""),
READ_ONLY_DATABASE(10436, "Database {0} is read-only", true),
+ UNEXPECTED_PARTITION_TRANSFORM_SPEC(10437, "Partition transforms are only
supported by Iceberg storage handler", true),
//========================== 20000 range starts here
========================//
diff --git
a/iceberg/iceberg-handler/src/test/java/org/apache/iceberg/mr/hive/TestHiveIcebergStorageHandlerNoScan.java
b/iceberg/iceberg-handler/src/test/java/org/apache/iceberg/mr/hive/TestHiveIcebergStorageHandlerNoScan.java
index 4995d795912..4941c1b25f3 100644
---
a/iceberg/iceberg-handler/src/test/java/org/apache/iceberg/mr/hive/TestHiveIcebergStorageHandlerNoScan.java
+++
b/iceberg/iceberg-handler/src/test/java/org/apache/iceberg/mr/hive/TestHiveIcebergStorageHandlerNoScan.java
@@ -428,6 +428,16 @@ public class TestHiveIcebergStorageHandlerNoScan {
Assert.assertEquals(spec, table.spec());
}
+ @Test
+ public void testInvalidCreateWithPartitionTransform() {
+ Assume.assumeTrue("Test on hive catalog is enough", testTableType ==
TestTables.TestTableType.HIVE_CATALOG);
+ String query = String.format("CREATE EXTERNAL TABLE customers (customer_id
BIGINT, first_name STRING, last_name " +
+ "STRING) PARTITIONED BY spec(TRUNCATE(2, last_name))
STORED AS ORC");
+ Assertions.assertThatThrownBy(() -> shell.executeStatement(query))
+ .isInstanceOf(IllegalArgumentException.class)
+ .hasMessageContaining("Partition transforms are only supported by
Iceberg storage handler");
+ }
+
@Test
public void testCreateDropTable() throws TException, IOException,
InterruptedException {
TableIdentifier identifier = TableIdentifier.of("default", "customers");
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/parse/SemanticAnalyzer.java
b/ql/src/java/org/apache/hadoop/hive/ql/parse/SemanticAnalyzer.java
index 7d7c5f4fe62..4dc08c96c4f 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/parse/SemanticAnalyzer.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/parse/SemanticAnalyzer.java
@@ -14495,6 +14495,8 @@ public class SemanticAnalyzer extends
BaseSemanticAnalyzer {
+ "'='" + fileFormat + "')");
}
}
+ } else if (partitionTransformSpecExists) {
+ throw new
SemanticException(ErrorMsg.UNEXPECTED_PARTITION_TRANSFORM_SPEC.getMsg());
}
}