Hello Impala Public Jenkins,

I'd like you to reexamine a change. Please visit

    https://gerrit.cloudera.org/25432

to look at the new patch set (#2).

Change subject: IMPALA-15399: Fix NULL result type for NULL operands in Calcite
......................................................................

IMPALA-15399: Fix NULL result type for NULL operands in Calcite

With the Calcite planner, some expressions on NULL operands return
the NULL type instead of the type the original planner returns:
- NULL * NULL (also +, -, / and %) returns NULL instead of DOUBLE.
- FALSE || NULL and NULL || NULL return NULL instead of BOOLEAN.

For arithmetic, ImpalaTypeSystemImpl.deriveArithmeticType calls
TypesUtil.getArithmeticResultType, which returns NULL when both
operands are NULL. ArithmeticExpr in the original planner defaults
that case to DOUBLE, so the backend never sees NULL_TYPE. This patch
adds the same DOUBLE default to deriveArithmeticType. Function
resolution then picks the DOUBLE version of the operator and casts
the NULL operands to DOUBLE.

For ||, ImpalaConcatOrOperator correctly infers BOOLEAN when both
operands are BOOLEAN or NULL. However, unlike the standard OR
operator, it does not infer operand types, so the NULL literal keeps
the NULL type. ImpalaConvertletTable.convertConcatOr then builds
OR(FALSE, null:NULL), which can be simplified to a NULL-typed literal.
When || is converted to OR, convertConcatOr now casts NULL-typed
operands to BOOLEAN. The CONCAT path is unchanged.

Testing:
- Added a test to QueryTest/calcite.test that checks the result types
  of NULL * NULL, NULL + NULL, NULL / NULL, NULL % NULL,
  FALSE || NULL and NULL || NULL.
- Ran test_calcite_planner.py::test_calcite_frontend.
- Ran CalcitePlannerTest.
- Ran expr-test ArithmeticExprs, CompoundPredicates and
  CompoundVerticalBarExpr locally, with expr-test forced to use the
  Calcite planner. The NULL operand type failures are gone. The
  remaining failures (x % 0, and NULL || 'abc' expected to fail) are
  pre-existing and not related to this change.

Change-Id: If8ac369da47fd63988569780c2315caebdab957c
Assisted-by: Claude Opus (Claude Code)
---
M 
java/calcite-planner/src/main/java/org/apache/impala/calcite/operators/ImpalaConvertletTable.java
M 
java/calcite-planner/src/main/java/org/apache/impala/calcite/type/ImpalaTypeSystemImpl.java
M testdata/workloads/functional-query/queries/QueryTest/calcite.test
3 files changed, 30 insertions(+), 6 deletions(-)


  git pull ssh://gerrit.cloudera.org:29418/Impala-ASF refs/changes/32/25432/2
--
To view, visit https://gerrit.cloudera.org/25432
To unsubscribe, visit https://gerrit.cloudera.org/settings

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: newpatchset
Gerrit-Change-Id: If8ac369da47fd63988569780c2315caebdab957c
Gerrit-Change-Number: 25432
Gerrit-PatchSet: 2
Gerrit-Owner: Wellington Cabrera <[email protected]>
Gerrit-Reviewer: Impala Public Jenkins <[email protected]>

Reply via email to