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

Julian Hyde commented on CALCITE-7758:
--------------------------------------

Solving this will require matching expressions that are not atoms, and any 
strategy for subexpression matching will increase the cost of simplification. 
Even a cost that is {{O(n)}} on the size of the expression becomes {{O(n^2)}} 
for the planner as a whole, and small cost increases become an unseen tax on 
planning.

I don't recall whether {{RexSimplify}} builds tables of expression fragments as 
it goes, but the benefit of this change should be weighed against increased 
cost.

> 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