[ 
https://issues.apache.org/jira/browse/CALCITE-7758?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18110024#comment-18110024
 ] 

Ruben Q L commented on CALCITE-7758:
------------------------------------

Perhaps the title is a bit ambiguous. The idea would be removing existing (but 
redundant) IS NOT NULL predicates.
IIUC, you'd like an example on a RexCall that can return NULL on non-NULL 
arguments, e.g.
{noformat}
IS_NOT_NULL(REGEXP_SUBSTR(myField, '[xw]yz')) AND REGEXP_SUBSTR(myField, 
'[xw]yz') || '123' = 'xyz123'
==>
REGEXP_SUBSTR(myField, '[xw]yz') || '123' = 'xyz123'
{noformat}
I think the proposed PR should work on that, I'll add a unit test to verify...

> RexSimplify does not absorb redundant IS NOT NULL on non-input-ref 
> sub-expressions in AND simplification
> --------------------------------------------------------------------------------------------------------
>
>                 Key: CALCITE-7758
>                 URL: https://issues.apache.org/jira/browse/CALCITE-7758
>             Project: Calcite
>          Issue Type: Improvement
>          Components: core
>            Reporter: Ruben Q L
>            Assignee: Ruben Q L
>            Priority: Major
>              Labels: pull-request-available
>             Fix For: 1.43.0
>
>
> The following simplification:
> {noformat}
> IS_NOT_NULL(x) AND (x + 1) < 10 
> =>
> (x + 1) < 10 
> {noformat}
> is correctly applied on RexSimplify (Unknown=FALSE) for RexInputRef and 
> RexFieldAccess (via simplifyAnd2ForUnknownAsFalse).
> However, if the expression X is e.g. a CAST, the simplification does not 
> occur:
> {noformat}
> IS_NOT_NULL(CAST(a)) AND (CAST(a) + 1) < 10 
> =>
> unchanged; should be: (CAST(a) + 1) < 10 
> {noformat}



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to