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

Julian Hyde edited comment on CALCITE-7041 at 5/25/25 5:50 PM:
---------------------------------------------------------------

Which component do you think should do this simplification? Several components, 
including RelBuilder and RexSimplify, already do these kinds of things.

Some simplifications are straightforward to humans but have to consider all 
orderings of terms, which is O(n!) in a conjunction of n terms. We can do such 
simplifications once per query, but we can't do them on every rule-firing (or 
invocation of RelBuilder).

If a simplification can build on information already known (e.g. a Sarg 
representing the range of x) then it becomes O(log n), and we can apply it in 
every rule-firing.


was (Author: julianhyde):
Which component do you think should do this simplification? Several components, 
including RelBuilder and RexSimplify, already do these kinds of things.

Some simplifications are straightforward to humans but have to consider all 
orderings of terms, which is O(n!) in a conjunction of n terms. We can do such 
simplifications once per query, but we can't do them on every rule-firing.

> Simplify simple contradicting expressions
> -----------------------------------------
>
>                 Key: CALCITE-7041
>                 URL: https://issues.apache.org/jira/browse/CALCITE-7041
>             Project: Calcite
>          Issue Type: Improvement
>            Reporter: Sergey Nuyanzin
>            Priority: Major
>
> For instance
> {code:sql}
> a > b AND b > a AND a IS NOT NULL AND b IS NOT NULL
> {code}
> or
> {code:sql}
> a >= b AND b > a AND a IS NOT NULL AND b IS NOT NULL
> {code}
> or
> {code:sql}
> a > b AND b >= a AND a IS NOT NULL AND b IS NOT NULL
> {code}
> could be simplified to {{FALSE}}
> and
> {code:sql}
> a >= b AND b >= a AND a IS NOT NULL AND b IS NOT NULL
> {code}
> could be simplified to {{a = b}}
> Probably there is something else



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

Reply via email to