Wellington Cabrera has uploaded this change for review. ( 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. Change-Id: Iccd7f761b855d46e8ff67875954f5eddad0a1ce9 Assisted-by: Claude Opus (Claude Code) --- M java/calcite-planner/src/main/java/org/apache/impala/calcite/service/ImpalaSqlValidatorImpl.java 1 file changed, 25 insertions(+), 0 deletions(-) git pull ssh://gerrit.cloudera.org:29418/Impala-ASF refs/changes/94/25394/1 -- 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: newchange Gerrit-Change-Id: Iccd7f761b855d46e8ff67875954f5eddad0a1ce9 Gerrit-Change-Number: 25394 Gerrit-PatchSet: 1 Gerrit-Owner: Wellington Cabrera <[email protected]>
