Impala Public Jenkins has submitted this change and it was merged. ( https://gerrit.cloudera.org/25394 )
Change subject: IMPALA-15404: Incorrect type for -cast(1.0 as float) ...................................................................... IMPALA-15404: Incorrect type for -cast(1.0 as float) The original parser turns unary minus on a non-literal into ArithmeticExpr(MULTIPLY, -1, e), whose result type is promoted by TypesUtil.getArithmeticResultType (FLOAT->DOUBLE, INT->BIGINT, ...). The Calcite planner typed UNARY_MINUS as ReturnTypes.ARG0 and kept the operand type, so -cast(1.0 as float) was FLOAT instead of DOUBLE. Override ImpalaSqlValidatorImpl.performUnconditionalRewrites to rewrite MINUS_PREFIX(x) into -1 * x, so it goes through Impala's multiply type promotion. Numeric and interval literals are skipped: Calcite already folds the sign into numeric literals, and INTERVAL -1 DAYS must stay a literal. Testing: - expr-test passes with expr-test forced to use the Calcite planner. - Added e2e tests to calcite.test covering unary minus on casts and columns of each numeric type, and on numeric and interval literals. Change-Id: Iccd7f761b855d46e8ff67875954f5eddad0a1ce9 Assisted-by: Claude Opus (Claude Code) Reviewed-on: https://gerrit.cloudera.org/25394 Reviewed-by: Michael Smith <[email protected]> Tested-by: Impala Public Jenkins <[email protected]> --- M java/calcite-planner/src/main/java/org/apache/impala/calcite/service/ImpalaSqlValidatorImpl.java M testdata/workloads/functional-query/queries/QueryTest/calcite.test 2 files changed, 55 insertions(+), 0 deletions(-) Approvals: Michael Smith: Looks good to me, approved Impala Public Jenkins: Verified -- To view, visit https://gerrit.cloudera.org/25394 To unsubscribe, visit https://gerrit.cloudera.org/settings Gerrit-Project: Impala-ASF Gerrit-Branch: master Gerrit-MessageType: merged Gerrit-Change-Id: Iccd7f761b855d46e8ff67875954f5eddad0a1ce9 Gerrit-Change-Number: 25394 Gerrit-PatchSet: 4 Gerrit-Owner: Wellington Cabrera <[email protected]> Gerrit-Reviewer: Aman Sinha <[email protected]> Gerrit-Reviewer: Impala Public Jenkins <[email protected]> Gerrit-Reviewer: Joe McDonnell <[email protected]> Gerrit-Reviewer: Michael Smith <[email protected]> Gerrit-Reviewer: Steve Carlin <[email protected]> Gerrit-Reviewer: Wellington Cabrera (968)
