xiedeyantu commented on code in PR #4324:
URL: https://github.com/apache/calcite/pull/4324#discussion_r2065913244


##########
core/src/test/resources/sql/planner.iq:
##########
@@ -88,4 +88,61 @@ EnumerableIntersect(all=[false])
     EnumerableValues(tuples=[[{ 0 }, { 1 }]])
 !plan
 
+# Test predicate push down with/without expand disjunction.
+!set planner-rules original
+with t1 (id1, col11, col12) as (values (1, 11, 111), (2, 12, 122), (3, 13, 
133), (4, 14, 144), (5, 15, 155)),
+t2 (id2, col21, col22) as (values (1, 21, 211), (2, 22, 222), (3, 23, 233), 
(4, 24, 244), (5, 25, 255)),
+t3 (id3, col31, col32) as (values (1, 31, 311), (2, 32, 322), (3, 33, 333), 
(4, 34, 344), (5, 35, 355))
+select * from t1, t2, t3 where id1 = id2 and id1 = id3 and
+(
+(col11 > 11 and col31 <= 32)
+or
+(col22 < 255 and col32 >= 344)
+);
++-----+-------+-------+-----+-------+-------+-----+-------+-------+
+| ID1 | COL11 | COL12 | ID2 | COL21 | COL22 | ID3 | COL31 | COL32 |
++-----+-------+-------+-----+-------+-------+-----+-------+-------+
+|   2 |    12 |   122 |   2 |    22 |   222 |   2 |    32 |   322 |
+|   4 |    14 |   144 |   4 |    24 |   244 |   4 |    34 |   344 |
++-----+-------+-------+-----+-------+-------+-----+-------+-------+
+(2 rows)
+
+!ok
+
+EnumerableMergeJoin(condition=[AND(=($0, $6), OR(AND(>($1, 11), <=($7, 32)), 
AND(<($5, 255), >=($8, 344))))], joinType=[inner])
+  EnumerableMergeJoin(condition=[=($0, $3)], joinType=[inner])
+    EnumerableValues(tuples=[[{ 1, 11, 111 }, { 2, 12, 122 }, { 3, 13, 133 }, 
{ 4, 14, 144 }, { 5, 15, 155 }]])
+    EnumerableValues(tuples=[[{ 1, 21, 211 }, { 2, 22, 222 }, { 3, 23, 233 }, 
{ 4, 24, 244 }, { 5, 25, 255 }]])
+  EnumerableValues(tuples=[[{ 1, 31, 311 }, { 2, 32, 322 }, { 3, 33, 333 }, { 
4, 34, 344 }, { 5, 35, 355 }]])
+!plan
+
+!set planner-rules "+CoreRules.EXPAND_FILTER_DISJUNCTION_LOCAL, 
+CoreRules.EXPAND_JOIN_DISJUNCTION_LOCAL"
+
+with t1 (id1, col11, col12) as (values (1, 11, 111), (2, 12, 122), (3, 13, 
133), (4, 14, 144), (5, 15, 155)),
+t2 (id2, col21, col22) as (values (1, 21, 211), (2, 22, 222), (3, 23, 233), 
(4, 24, 244), (5, 25, 255)),
+t3 (id3, col31, col32) as (values (1, 31, 311), (2, 32, 322), (3, 33, 333), 
(4, 34, 344), (5, 35, 355))
+select * from t1, t2, t3 where id1 = id2 and id1 = id3 and
+(
+(col11 > 11 and col31 <= 32)
+or
+(col22 < 255 and col32 >= 344)
+);
++-----+-------+-------+-----+-------+-------+-----+-------+-------+
+| ID1 | COL11 | COL12 | ID2 | COL21 | COL22 | ID3 | COL31 | COL32 |
++-----+-------+-------+-----+-------+-------+-----+-------+-------+
+|   2 |    12 |   122 |   2 |    22 |   222 |   2 |    32 |   322 |
+|   4 |    14 |   144 |   4 |    24 |   244 |   4 |    34 |   344 |
++-----+-------+-------+-----+-------+-------+-----+-------+-------+
+(2 rows)
+
+!ok
+
+EnumerableHashJoin(condition=[AND(=($0, $6), OR(AND(>($1, 11), <=($7, 32)), 
AND(<($5, 255), >=($8, 344))))], joinType=[inner])
+  EnumerableMergeJoin(condition=[AND(=($0, $3), OR(>($1, 11), <($5, 255)))], 
joinType=[inner])
+    EnumerableValues(tuples=[[{ 1, 11, 111 }, { 2, 12, 122 }, { 3, 13, 133 }, 
{ 4, 14, 144 }, { 5, 15, 155 }]])
+    EnumerableValues(tuples=[[{ 1, 21, 211 }, { 2, 22, 222 }, { 3, 23, 233 }, 
{ 4, 24, 244 }, { 5, 25, 255 }]])
+  EnumerableCalc(expr#0..2=[{inputs}], expr#3=[32], expr#4=[<=($t1, $t3)], 
expr#5=[344], expr#6=[>=($t2, $t5)], expr#7=[OR($t4, $t6)], 
proj#0..2=[{exprs}], $condition=[$t7])
+    EnumerableValues(tuples=[[{ 1, 31, 311 }, { 2, 32, 322 }, { 3, 33, 333 }, 
{ 4, 34, 344 }, { 5, 35, 355 }]])
+!plan
+

Review Comment:
   Please add `!set planner-rules original` here to avoid affecting the 
following cases.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to