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

xiong duan commented on CALCITE-1794:
-------------------------------------

For example:
{code:java}
select * from "scott".emp where deptno <> 20 and deptno = 25{code}
Before the fix, the physical plan is:
{noformat}
EnumerableCalc(expr#0..7=[{inputs}], expr#8=[CAST($t7):INTEGER], expr#9=[20], 
expr#10=[<>($t8, $t9)], expr#11=[25], expr#12=[=($t8, $t11)], 
expr#13=[AND($t10, $t12)], proj#0..7=[{exprs}], $condition=[$t13])
  EnumerableTableScan(table=[[scott, EMP]]){noformat}
After the fix, the physical plan is:
{noformat}
EnumerableCalc(expr#0..7=[{inputs}], expr#8=[CAST($t7):INTEGER], expr#9=[25], 
expr#10=[=($t8, $t9)], proj#0..7=[{exprs}], $condition=[$t10])
  EnumerableTableScan(table=[[scott, EMP]]){noformat}
But If the SQL is
{code:java}
select * from "scott".emp where deptno = 25 and deptno <> 20{code}
This SQL can be simplified using "Pull-Up-Predicate", don't need to use the 
SARG.

> Simplify AND numeric comparisons when overlapping
> -------------------------------------------------
>
>                 Key: CALCITE-1794
>                 URL: https://issues.apache.org/jira/browse/CALCITE-1794
>             Project: Calcite
>          Issue Type: Improvement
>          Components: core
>    Affects Versions: 1.29.0
>            Reporter: Remus Rusanu
>            Assignee: xiong duan
>            Priority: Major
>              Labels: pull-request-available
>          Time Spent: 20m
>  Remaining Estimate: 0h
>
> Expressions such as {{$1<>1 and $1=2}} can be simplified to {{$1=2}}. Similar 
> {{$1>10 AND $1>20}} can be simplified to {{$1>20}}. Such expressions are 
> produced by the proposed solution for CALCITE-1790 (simplify boolean CASE to 
> complex AND/OR).



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

Reply via email to