xiong duan created CALCITE-4993:
-----------------------------------
Summary: 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
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)