This is an automated email from the ASF dual-hosted git repository.
michaelsmith pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/impala.git
The following commit(s) were added to refs/heads/master by this push:
new 6cf21464b IMPALA-14569: Fix IllegalStateException in partition pruning
on type mismatch
6cf21464b is described below
commit 6cf21464b4bc80bd7a0219e4e4e2f42da694476b
Author: Peter Rozsa <[email protected]>
AuthorDate: Fri Nov 21 15:41:23 2025 +0100
IMPALA-14569: Fix IllegalStateException in partition pruning on type
mismatch
This fixes an IllegalStateException in HdfsPartitionPruner when
evaluating 'IN' predicates whose consist of two compatible types, for
example DATE and STRING: date_col in (<date as string>).
Previously, 'canEvalUsingPartitionMd' did not check if the slot type
matched the literal type. This caused the frontend to attempt invalid
comparisons via 'LiteralExpr.compareTo', leading to
IllegalStateException or incorrect pruning.
The fix ensures 'canEvalUsingPartitionMd' returns false on type
mismatches, deferring evaluation to the backend where proper casting
occurs.
Testing:
- Added regression test in hdfs-partition-pruning.test.
Change-Id: Idc226a628c8df559329a060cb963b81e27e21eda
Reviewed-on: http://gerrit.cloudera.org:8080/23706
Reviewed-by: Impala Public Jenkins <[email protected]>
Tested-by: Impala Public Jenkins <[email protected]>
---
.../org/apache/impala/planner/HdfsPartitionPruner.java | 3 +++
.../queries/QueryTest/hdfs-partition-pruning.test | 17 +++++++++++++++++
tests/query_test/test_queries.py | 4 ++++
3 files changed, 24 insertions(+)
diff --git
a/fe/src/main/java/org/apache/impala/planner/HdfsPartitionPruner.java
b/fe/src/main/java/org/apache/impala/planner/HdfsPartitionPruner.java
index 56a7e6dba..b368c4a6a 100644
--- a/fe/src/main/java/org/apache/impala/planner/HdfsPartitionPruner.java
+++ b/fe/src/main/java/org/apache/impala/planner/HdfsPartitionPruner.java
@@ -285,6 +285,9 @@ public class HdfsPartitionPruner {
if (slot == null) return false;
for (int i = 1; i < expr.getChildren().size(); ++i) {
if (!Expr.IS_LITERAL.apply(expr.getChild(i))) return false;
+ // Mismatched types should be evaluated with their respective casts
+ // in the backend.
+ if (!slot.getType().equals(expr.getChild(i).getType())) return false;
}
return true;
}
diff --git
a/testdata/workloads/functional-query/queries/QueryTest/hdfs-partition-pruning.test
b/testdata/workloads/functional-query/queries/QueryTest/hdfs-partition-pruning.test
new file mode 100644
index 000000000..185232aab
--- /dev/null
+++
b/testdata/workloads/functional-query/queries/QueryTest/hdfs-partition-pruning.test
@@ -0,0 +1,17 @@
+====
+---- QUERY
+# IMPALA-14569: failing partition pruning due to mismatchig partition types
+create table a(id int) partitioned by (date_stored_as_string string);
+create table b(id int) partitioned by (date_stored_as_date date);
+insert into a(id, date_stored_as_string) values(1, '2025-12-12');
+insert into a(id, date_stored_as_string) values(1, '2025-12-10');
+insert into b(id, date_stored_as_date) values(1, '2025-12-12');
+select * from b
+left outer join a on date_stored_as_date = date_stored_as_string
+where date_stored_as_date in ( '2025-12-12');
+---- RESULTS
+1,2025-12-12,1,'2025-12-12'
+---- TYPES
+INT,DATE,INT,STRING
+---- RUNTIME_PROFILE
+row_regex:.*HDFS partitions=1/2 files=1 size=2B
diff --git a/tests/query_test/test_queries.py b/tests/query_test/test_queries.py
index 3b1496bf8..41e3463a3 100644
--- a/tests/query_test/test_queries.py
+++ b/tests/query_test/test_queries.py
@@ -358,6 +358,10 @@ class TestHdfsQueries(ImpalaTestSuite):
def test_file_partitions(self, vector):
self.run_test_case('QueryTest/hdfs-partitions', vector)
+ def test_partition_pruning(self, vector, unique_database):
+ self.run_test_case('QueryTest/hdfs-partition-pruning',
+ vector, unique_database)
+
class TestPartitionKeyScans(ImpalaTestSuite):
"""Tests for queries that exercise partition key scan optimisation. These