Wellington Cabrera has posted comments on this change. ( 
https://gerrit.cloudera.org/25432 )

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


Patch Set 4:

> Patch Set 3:
>
> (1 comment)

Good question. For this code path it's only AND and OR: they're the only 
operators (besides CAST) in NO_CAST_OPERATORS, so they skip operand coercion. 
Every other call goes through FunctionResolver.getSupertypeFunction / 
getCastedArgTypes, which casts NULL operands to the signature types. 
pullFactors/toCnf also only rewrite AND/OR/NOT, and NOT's operand is already 
cast by then. Impala has no logical XOR; ^ is bitwise XOR on integers. I 
reworded the comment to explain why only AND/OR need this.

Checking the bitwise operators did turn up a related problem, though: NULL & 
NULL returned the NULL type instead of INT. & used Calcite's BITAND_OPERATOR, 
whose least-restrictive return type is NULL for two NULL operands and never 
reaches Impala's type system. I fixed it in this patch set the same way as +, 
-, *, /, % and DIV: a custom BITAND operator in ImpalaCustomOperatorTable that 
gets its type from deriveArithmeticType. deriveArithmeticType now types 
BITAND/BITOR/BITXOR like DIV (assignment compatible type, INT for NULL, NULL), 
matching ArithmeticExpr. I added a calcite.test case for it.

| and ^ don't parse under Calcite yet, ~ fails in the lexer, and bitxor(NULL, 
NULL) fails validation. Those are separate parser/function issues, so I'll file 
a follow-up Jira.


--
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: comment
Gerrit-Change-Id: If8ac369da47fd63988569780c2315caebdab957c
Gerrit-Change-Number: 25432
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)
Gerrit-Comment-Date: Mon, 23 Nov 2026 20:09:11 +0000
Gerrit-HasComments: No

Reply via email to