Ruben Q L created HIVE-29832:
--------------------------------
Summary: Improve predicate simplification around CAST
Key: HIVE-29832
URL: https://issues.apache.org/jira/browse/HIVE-29832
Project: Hive
Issue Type: Improvement
Reporter: Ruben Q L
With Calcite upgrade to 1.42 (HIVE-29641) certain simplifications were "lost"
due to Calcite RexSimplifier code being more conservative.
For example, this predicate in
ql/src/test/results/clientpositive/llap/input8.q.out (around line 41)
{noformat}
UDFToInteger((UDFToDouble(key) - null)) (type: int)
{noformat}
is no longer simplified to {{null (type: int)}} , as it used to be on older
Calcite versions.
The reason for that is that Calcite now avoids simplifying away expressions
that may throw at runtime (so that a runtime exception is not hidden due to
simplification). In the case of CAST, only "lossless cast" (see Calcite
RexSimplify) are considered safe (see point 3 in the description of
https://github.com/apache/hive/pull/6523).
In the case of HIVE, CAST (even "non-lossless" ones) will not throw at runtime
(they would return NULL), so this type of simplifications should be valid on
Hive.
To be studied how to bring them back: improve Calcite RexSimplify? use
SAFE_CAST operator instead of CAST in Hive (which seem more accurate
considering the Hive behavior)?
--
This message was sent by Atlassian Jira
(v8.20.10#820010)