This is an automated email from the ASF dual-hosted git repository.

stigahuang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/impala.git

commit 8fa383d9eb3961b3bbf8896d6a9f117b65bf8c84
Author: Steve Carlin <scar...@cloudera.com>
AuthorDate: Wed Jun 11 13:01:06 2025 -0700

    IMPALA-14166: Calcite Planner: Ensure 'unsupported' functions are handled 
correctly
    
    There are some datasketches functions which return a Function
    object where the "isUnsupported" method returns true.
    
    This needs to be explicitly handled in the Calcite code as unsupported.
    
    Change-Id: Ic2c4a96005fc7571bde28643ea4cecda61839c77
    Reviewed-on: http://gerrit.cloudera.org:8080/23041
    Tested-by: Impala Public Jenkins <impala-public-jenk...@cloudera.com>
    Reviewed-by: Riza Suminto <riza.sumi...@cloudera.com>
---
 .../java/org/apache/impala/calcite/functions/FunctionResolver.java | 6 ++++++
 testdata/workloads/functional-query/queries/QueryTest/calcite.test | 7 +++++++
 2 files changed, 13 insertions(+)

diff --git 
a/java/calcite-planner/src/main/java/org/apache/impala/calcite/functions/FunctionResolver.java
 
b/java/calcite-planner/src/main/java/org/apache/impala/calcite/functions/FunctionResolver.java
index d5544c1be..b3e4e0baa 100644
--- 
a/java/calcite-planner/src/main/java/org/apache/impala/calcite/functions/FunctionResolver.java
+++ 
b/java/calcite-planner/src/main/java/org/apache/impala/calcite/functions/FunctionResolver.java
@@ -222,6 +222,12 @@ public class FunctionResolver {
 
     if (fn == null) {
       LOG.debug("Failed to find function " + lowercaseName);
+      return null;
+    }
+
+    if (fn.isUnsupported()) {
+      LOG.info("Function " + lowercaseName + " is not supported for given 
type.");
+      return null;
     }
 
     return fn;
diff --git a/testdata/workloads/functional-query/queries/QueryTest/calcite.test 
b/testdata/workloads/functional-query/queries/QueryTest/calcite.test
index 711694664..121060cf0 100644
--- a/testdata/workloads/functional-query/queries/QueryTest/calcite.test
+++ b/testdata/workloads/functional-query/queries/QueryTest/calcite.test
@@ -1060,3 +1060,10 @@ select * from functional.alltypes_hive_view where id = 0;
 ---- TYPES
 INT, BOOLEAN, TINYINT, SMALLINT, INT, BIGINT, FLOAT, DOUBLE, STRING, STRING, 
TIMESTAMP, INT, INT
 ====
+---- QUERY
+# should fail at analysis time, not runtime
+# IMPALA-14199: We can improve on this error message
+select ds_hll_sketch(smallint_col) from functional_parquet.alltypessmall;
+---- CATCH
+Cannot infer return type for DS_HLL_SKETCH; operand types: [SMALLINT]
+====

Reply via email to