[
https://issues.apache.org/jira/browse/CALCITE-7722?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18105347#comment-18105347
]
Ruben Q L edited comment on CALCITE-7722 at 8/17/26 7:17 PM:
-------------------------------------------------------------
[~julianhyde] , the claim is that in RexSimplify an IS [NOT] NULL on a safe
operator with Strong policy ANY and unsafe operands can be further simplified
(probably that would be a better title).
For example, this IS NOT NULL on a multiplication (which is a safe operator,
with Strong ANY), containing a non-lossless CAST (i.e. an "unsafe" operand) at
the moment is not simplified:
{noformat}
IS NOT NULL(CAST(myStr AS DOUBLE) + 1.0)
{noformat}
And it could be:
{noformat}
IS NOT NULL(CAST(myStr AS DOUBLE) + 1.0) => IS NOT NULL(CAST(myStr AS DOUBLE))
AND IS NOT NULL(1.0) => IS NOT NULL(CAST(myStr AS DOUBLE))
{noformat}
was (Author: rubenql):
[~julianhyde] , the claim is that in RexSimplify, an IS [NOT] NULL on a safe
operator with Strong policy ANY and unsafe operands can be further simplified
(probably that would be a better title).
For example, this IS NOT NULL on a multiplication (which is a safe operation),
containing a non-lossless CAST (i.e. an "unsafe" operand) at the moment is not
simplified:
{noformat}
IS NOT NULL(CAST(myStr AS DOUBLE) + 1.0)
{noformat}
And it could be:
{noformat}
IS NOT NULL(CAST(myStr AS DOUBLE) + 1.0) => IS NOT NULL(CAST(myStr AS DOUBLE))
AND IS NOT NULL(1.0) => IS NOT NULL(CAST(myStr AS DOUBLE))
{noformat}
> RexSimplify IS [NOT] NULL over a Strong.ANY call is no longer simplified when
> the call itself is unsafe
> -------------------------------------------------------------------------------------------------------
>
> Key: CALCITE-7722
> URL: https://issues.apache.org/jira/browse/CALCITE-7722
> Project: Calcite
> Issue Type: Improvement
> Reporter: Thomas Rebele
> Assignee: Ruben Q L
> Priority: Major
> Labels: pull-request-available
>
> RexSimplify.simplifyIsNotNull / simplifyIsNull currently bail out of the
> whole simplification when the input RexCall is not fully safe (i.e.
> isSafeExpression(a) == false). This is stricter than necessary for operators
> with Strong.Policy.ANY, where IS [NOT] NULL(f(a, b, ...)) is semantically
> equivalent to IS [NOT] NULL(a) OR/AND IS [NOT] NULL(b) OR/AND ... — the
> operator itself does not need to be evaluated to compute the result.
> Example (regression for downstream projects such as Hive):
> {code}
> Before (≤ 1.34):
> IS NOT NULL(CAST(key AS DOUBLE) + 1.0) → IS NOT NULL(CAST(key AS DOUBLE))
> After (≥ 1.35):
> IS NOT NULL(CAST(key AS DOUBLE) + 1.0) → (unchanged)
> {code}
> The rewrite is dropped because CAST(key AS DOUBLE) + 1.0 is a non-lossless
> cast wrapped in a +, so isSafeExpression returns false, even though + is
> Strong.ANY and the distribution is a valid rewrite regardless of the outer
> call's safety.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)