Hello Aman Sinha, Joe McDonnell, Steve Carlin, Michael Smith, Impala Public
Jenkins,
I'd like you to reexamine a change. Please visit
https://gerrit.cloudera.org/25394
to look at the new patch set (#3).
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)
---
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(-)
git pull ssh://gerrit.cloudera.org:29418/Impala-ASF refs/changes/94/25394/3
--
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: newpatchset
Gerrit-Change-Id: Iccd7f761b855d46e8ff67875954f5eddad0a1ce9
Gerrit-Change-Number: 25394
Gerrit-PatchSet: 3
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]>