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

xiong duan commented on CALCITE-4993:
-------------------------------------

Hi [~julianhyde] This is another issue different from CALCITE-1794. 
CALCITE-1794 just addresses EQUALS and NOT-EQUALS comparison. Because they use 
the same  *LEAST_RESTRICTIVE* strategy to validate the parameter. Other 
comparators use the *COMPARE* strategy{*}.{*} 

As mentioned above, The left RexNode([CAST($t0): INTEGER NOT NULL]  and $t0) 
become different, That's why can't be simplified.

> Simplify EQUALS or NOT-EQUALS with other number comparison
> ----------------------------------------------------------
>
>                 Key: CALCITE-4993
>                 URL: https://issues.apache.org/jira/browse/CALCITE-4993
>             Project: Calcite
>          Issue Type: Bug
>          Components: core
>    Affects Versions: 1.29.0
>            Reporter: xiong duan
>            Priority: Major
>
> For example(SELECT expression FROM table), The Plan is EnumerableCalc 
> description:
> 1:
> {code:java}
> "cust_id"<>5 and "cust_id">3 and "cust_id"< 10{code}
> Before:
> {noformat}
> expr#0..1=[{inputs}], expr#2=[CAST($t0):INTEGER NOT NULL], expr#3=[5], 
> expr#4=[<>($t2, $t3)], expr#5=[3], expr#6=[>($t0, $t5)], expr#7=[10], 
> expr#8=[<($t0, $t7)], expr#9=[AND($t4, $t6, $t8)], EXPR$0=[$t9]{noformat}
> After:
> {noformat}
> (expr#0..1=[{inputs}], expr#2=[Sarg[(3..5), (5..10)]], expr#3=[SEARCH($t0, 
> $t2)], EXPR$0=[$t3]){noformat}
> 2:
> {code:java}
> "cust_id"=5 and "cust_id">3 and "cust_id"< 10{code}
> Before:
> {noformat}
> expr#0..1=[{inputs}], expr#2=[CAST($t0):INTEGER NOT NULL], expr#3=[5], 
> expr#4=[=($t2, $t3)], expr#5=[3], expr#6=[>($t0, $t5)], expr#7=[10], 
> expr#8=[<($t0, $t7)], expr#9=[AND($t4, $t6, $t8)], EXPR$0=[$t9]{noformat}
> After:
> {noformat}
> expr#0..1=[{inputs}], expr#2=[5], expr#3=[=($t0, $t2)], EXPR$0=[$t3]{noformat}
> 3:
> {code:java}
> "cust_id"=5 and "cust_id">6 and "cust_id"< 10{code}
> Before:
> {noformat}
> expr#0..1=[{inputs}], expr#2=[CAST($t0):INTEGER NOT NULL], expr#3=[5], 
> expr#4=[=($t2, $t3)], expr#5=[6], expr#6=[>($t0, $t5)], expr#7=[10], 
> expr#8=[<($t0, $t7)], expr#9=[AND($t4, $t6, $t8)], EXPR$0=[$t9]{noformat}
> After:
> {noformat}
> expr#0..1=[{inputs}], expr#2=[false], EXPR$0=[$t2]{noformat}



--
This message was sent by Atlassian Jira
(v8.20.1#820001)

Reply via email to