This is an automated email from the ASF dual-hosted git repository. joemcdonnell pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/impala.git
commit 922443da463f64443d7796fb1fb3435a6f513e83 Author: Steve Carlin <[email protected]> AuthorDate: Tue Jun 10 06:31:57 2025 -0700 IMPALA-14165: Type coercion code accidentally omitted from analysis On the first cut of creating the Calcite planner, the Calcite planner was standalone and ran its own JniFrontend. In the current version, the parsing, validating, and single node planning is called from the Impala framework. There is some code in the first cut regarding the "ImpalaTypeCoercionFactory" class which handles deriving the correct data type for various expressions, for instance (found in exprs.test): select count(*) from alltypesagg where 10.1 in (tinyint_col, smallint_col, int_col, bigint_col, float_col, double_col) Without this patch, the query returns the following error: UDF ERROR: Decimal expression overflowed This code can be found in CalciteValidator.java, but was accidentally omitted from CalciteAnalysisDriver. Change-Id: I74c4c714504400591d1ec6313f040191613c25d9 Reviewed-on: http://gerrit.cloudera.org:8080/23039 Tested-by: Impala Public Jenkins <[email protected]> Reviewed-by: Steve Carlin <[email protected]> --- .../apache/impala/calcite/service/CalciteAnalysisDriver.java | 3 +++ .../workloads/functional-query/queries/QueryTest/calcite.test | 10 ++++++++++ 2 files changed, 13 insertions(+) diff --git a/java/calcite-planner/src/main/java/org/apache/impala/calcite/service/CalciteAnalysisDriver.java b/java/calcite-planner/src/main/java/org/apache/impala/calcite/service/CalciteAnalysisDriver.java index e6bb6d2b7..32634cd11 100644 --- a/java/calcite-planner/src/main/java/org/apache/impala/calcite/service/CalciteAnalysisDriver.java +++ b/java/calcite-planner/src/main/java/org/apache/impala/calcite/service/CalciteAnalysisDriver.java @@ -43,6 +43,7 @@ import org.apache.impala.authorization.AuthorizationContext; import org.apache.impala.authorization.AuthorizationFactory; import org.apache.impala.calcite.operators.ImpalaOperatorTable; import org.apache.impala.calcite.schema.ImpalaCalciteCatalogReader; +import org.apache.impala.calcite.type.ImpalaTypeCoercionFactory; import org.apache.impala.calcite.type.ImpalaTypeSystemImpl; import org.apache.impala.calcite.util.SimplifiedAnalyzer; import org.apache.impala.calcite.validate.ImpalaConformance; @@ -119,6 +120,8 @@ public class CalciteAnalysisDriver implements AnalysisDriver { // without this) .withIdentifierExpansion(true) .withConformance(ImpalaConformance.INSTANCE) + .withTypeCoercionEnabled(true) + .withTypeCoercionFactory(new ImpalaTypeCoercionFactory()) ); validatedNode_ = sqlValidator_.validate(parsedStmt_.getParsedSqlNode()); return new CalciteAnalysisResult(this); diff --git a/testdata/workloads/functional-query/queries/QueryTest/calcite.test b/testdata/workloads/functional-query/queries/QueryTest/calcite.test index 121060cf0..3013d7965 100644 --- a/testdata/workloads/functional-query/queries/QueryTest/calcite.test +++ b/testdata/workloads/functional-query/queries/QueryTest/calcite.test @@ -1066,4 +1066,14 @@ INT, BOOLEAN, TINYINT, SMALLINT, INT, BIGINT, FLOAT, DOUBLE, STRING, STRING, TIM select ds_hll_sketch(smallint_col) from functional_parquet.alltypessmall; ---- CATCH Cannot infer return type for DS_HLL_SKETCH; operand types: [SMALLINT] +===== +---- QUERY +# This test case ensures that the TypeCoercion code is in place, which gets kicked +# in with the "in" clause +select count(*) from functional.alltypesagg +where 10.1 not in (tinyint_col, smallint_col, int_col, bigint_col, float_col, double_col) +---- RESULTS +8990 +---- TYPES +bigint ====
