Skip to content

Commit 74bbf47

Browse files
committed
Move ExpandDisjunctionForJoinInputsRule test from planner.iq to hep.iq
1 parent 6ba1b53 commit 74bbf47

File tree

2 files changed

+74
-69
lines changed

2 files changed

+74
-69
lines changed

core/src/test/resources/sql/hep.iq

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,4 +164,78 @@ EnumerableCalc(expr#0..2=[{inputs}], MGR=[$t1], COMM=[$t2])
164164
!}
165165
!set hep-rules original
166166

167+
# Test predicate push down with/without expand disjunction.
168+
with t1 (id1, col11, col12) as (values (1, 11, 111), (2, 12, 122), (3, 13, 133), (4, 14, 144), (5, 15, 155)),
169+
t2 (id2, col21, col22) as (values (1, 21, 211), (2, 22, 222), (3, 23, 233), (4, 24, 244), (5, 25, 255)),
170+
t3 (id3, col31, col32) as (values (1, 31, 311), (2, 32, 322), (3, 33, 333), (4, 34, 344), (5, 35, 355))
171+
select * from t1, t2, t3 where id1 = id2 and id1 = id3 and
172+
(
173+
(col11 > 11 and col31 <= 32)
174+
or
175+
(col22 < 255 and col32 >= 344)
176+
);
177+
+-----+-------+-------+-----+-------+-------+-----+-------+-------+
178+
| ID1 | COL11 | COL12 | ID2 | COL21 | COL22 | ID3 | COL31 | COL32 |
179+
+-----+-------+-------+-----+-------+-------+-----+-------+-------+
180+
| 2 | 12 | 122 | 2 | 22 | 222 | 2 | 32 | 322 |
181+
| 4 | 14 | 144 | 4 | 24 | 244 | 4 | 34 | 344 |
182+
+-----+-------+-------+-----+-------+-------+-----+-------+-------+
183+
(2 rows)
184+
185+
!ok
186+
187+
EnumerableMergeJoin(condition=[AND(=($0, $6), OR(AND(>($1, 11), <=($7, 32)), AND(<($5, 255), >=($8, 344))))], joinType=[inner])
188+
EnumerableMergeJoin(condition=[=($0, $3)], joinType=[inner])
189+
EnumerableValues(tuples=[[{ 1, 11, 111 }, { 2, 12, 122 }, { 3, 13, 133 }, { 4, 14, 144 }, { 5, 15, 155 }]])
190+
EnumerableValues(tuples=[[{ 1, 21, 211 }, { 2, 22, 222 }, { 3, 23, 233 }, { 4, 24, 244 }, { 5, 25, 255 }]])
191+
EnumerableValues(tuples=[[{ 1, 31, 311 }, { 2, 32, 322 }, { 3, 33, 333 }, { 4, 34, 344 }, { 5, 35, 355 }]])
192+
!plan
193+
194+
!set hep-rules "
195+
+CoreRules.EXPAND_FILTER_DISJUNCTION_LOCAL,
196+
+CoreRules.EXPAND_JOIN_DISJUNCTION_LOCAL,
197+
+CoreRules.JOIN_CONDITION_PUSH,
198+
+CoreRules.FILTER_INTO_JOIN"
199+
200+
with t1 (id1, col11, col12) as (values (1, 11, 111), (2, 12, 122), (3, 13, 133), (4, 14, 144), (5, 15, 155)),
201+
t2 (id2, col21, col22) as (values (1, 21, 211), (2, 22, 222), (3, 23, 233), (4, 24, 244), (5, 25, 255)),
202+
t3 (id3, col31, col32) as (values (1, 31, 311), (2, 32, 322), (3, 33, 333), (4, 34, 344), (5, 35, 355))
203+
select * from t1, t2, t3 where id1 = id2 and id1 = id3 and
204+
(
205+
(col11 > 11 and col31 <= 32)
206+
or
207+
(col22 < 255 and col32 >= 344)
208+
);
209+
+-----+-------+-------+-----+-------+-------+-----+-------+-------+
210+
| ID1 | COL11 | COL12 | ID2 | COL21 | COL22 | ID3 | COL31 | COL32 |
211+
+-----+-------+-------+-----+-------+-------+-----+-------+-------+
212+
| 2 | 12 | 122 | 2 | 22 | 222 | 2 | 32 | 322 |
213+
| 4 | 14 | 144 | 4 | 24 | 244 | 4 | 34 | 344 |
214+
+-----+-------+-------+-----+-------+-------+-----+-------+-------+
215+
(2 rows)
216+
217+
!ok
218+
219+
!if (use_old_decorr) {
220+
EnumerableCalc(expr#0..8=[{inputs}], proj#0..8=[{exprs}])
221+
EnumerableHashJoin(condition=[AND(=($0, $6), OR(AND(>($1, 11), <=($7, 32)), AND(<($5, 255), >=($8, 344))))], joinType=[inner])
222+
EnumerableMergeJoin(condition=[AND(=($0, $3), OR(>($1, 11), <($5, 255)))], joinType=[inner])
223+
EnumerableValues(tuples=[[{ 1, 11, 111 }, { 2, 12, 122 }, { 3, 13, 133 }, { 4, 14, 144 }, { 5, 15, 155 }]])
224+
EnumerableValues(tuples=[[{ 1, 21, 211 }, { 2, 22, 222 }, { 3, 23, 233 }, { 4, 24, 244 }, { 5, 25, 255 }]])
225+
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])
226+
EnumerableValues(tuples=[[{ 1, 31, 311 }, { 2, 32, 322 }, { 3, 33, 333 }, { 4, 34, 344 }, { 5, 35, 355 }]])
227+
!plan
228+
!}
229+
230+
!if (use_new_decorr) {
231+
EnumerableHashJoin(condition=[AND(=($0, $6), OR(AND(>($1, 11), <=($7, 32)), AND(<($5, 255), >=($8, 344))))], joinType=[inner])
232+
EnumerableMergeJoin(condition=[AND(=($0, $3), OR(>($1, 11), <($5, 255)))], joinType=[inner])
233+
EnumerableValues(tuples=[[{ 1, 11, 111 }, { 2, 12, 122 }, { 3, 13, 133 }, { 4, 14, 144 }, { 5, 15, 155 }]])
234+
EnumerableValues(tuples=[[{ 1, 21, 211 }, { 2, 22, 222 }, { 3, 23, 233 }, { 4, 24, 244 }, { 5, 25, 255 }]])
235+
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])
236+
EnumerableValues(tuples=[[{ 1, 31, 311 }, { 2, 32, 322 }, { 3, 33, 333 }, { 4, 34, 344 }, { 5, 35, 355 }]])
237+
!plan
238+
!}
239+
!set hep-rules original
240+
167241
# End hep.iq

core/src/test/resources/sql/planner.iq

Lines changed: 0 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -310,75 +310,6 @@ EnumerableMinus(all=[false])
310310
EnumerableValues(tuples=[[{ 1.0 }, { 4.0 }, { null }]])
311311
!plan
312312

313-
# Test predicate push down with/without expand disjunction.
314-
with t1 (id1, col11, col12) as (values (1, 11, 111), (2, 12, 122), (3, 13, 133), (4, 14, 144), (5, 15, 155)),
315-
t2 (id2, col21, col22) as (values (1, 21, 211), (2, 22, 222), (3, 23, 233), (4, 24, 244), (5, 25, 255)),
316-
t3 (id3, col31, col32) as (values (1, 31, 311), (2, 32, 322), (3, 33, 333), (4, 34, 344), (5, 35, 355))
317-
select * from t1, t2, t3 where id1 = id2 and id1 = id3 and
318-
(
319-
(col11 > 11 and col31 <= 32)
320-
or
321-
(col22 < 255 and col32 >= 344)
322-
);
323-
+-----+-------+-------+-----+-------+-------+-----+-------+-------+
324-
| ID1 | COL11 | COL12 | ID2 | COL21 | COL22 | ID3 | COL31 | COL32 |
325-
+-----+-------+-------+-----+-------+-------+-----+-------+-------+
326-
| 2 | 12 | 122 | 2 | 22 | 222 | 2 | 32 | 322 |
327-
| 4 | 14 | 144 | 4 | 24 | 244 | 4 | 34 | 344 |
328-
+-----+-------+-------+-----+-------+-------+-----+-------+-------+
329-
(2 rows)
330-
331-
!ok
332-
333-
EnumerableMergeJoin(condition=[AND(=($0, $6), OR(AND(>($1, 11), <=($7, 32)), AND(<($5, 255), >=($8, 344))))], joinType=[inner])
334-
EnumerableMergeJoin(condition=[=($0, $3)], joinType=[inner])
335-
EnumerableValues(tuples=[[{ 1, 11, 111 }, { 2, 12, 122 }, { 3, 13, 133 }, { 4, 14, 144 }, { 5, 15, 155 }]])
336-
EnumerableValues(tuples=[[{ 1, 21, 211 }, { 2, 22, 222 }, { 3, 23, 233 }, { 4, 24, 244 }, { 5, 25, 255 }]])
337-
EnumerableValues(tuples=[[{ 1, 31, 311 }, { 2, 32, 322 }, { 3, 33, 333 }, { 4, 34, 344 }, { 5, 35, 355 }]])
338-
!plan
339-
340-
!set planner-rules "
341-
+CoreRules.EXPAND_FILTER_DISJUNCTION_LOCAL"
342-
343-
with t1 (id1, col11, col12) as (values (1, 11, 111), (2, 12, 122), (3, 13, 133), (4, 14, 144), (5, 15, 155)),
344-
t2 (id2, col21, col22) as (values (1, 21, 211), (2, 22, 222), (3, 23, 233), (4, 24, 244), (5, 25, 255)),
345-
t3 (id3, col31, col32) as (values (1, 31, 311), (2, 32, 322), (3, 33, 333), (4, 34, 344), (5, 35, 355))
346-
select * from t1, t2, t3 where id1 = id2 and id1 = id3 and
347-
(
348-
(col11 > 11 and col31 <= 32)
349-
or
350-
(col22 < 255 and col32 >= 344)
351-
);
352-
+-----+-------+-------+-----+-------+-------+-----+-------+-------+
353-
| ID1 | COL11 | COL12 | ID2 | COL21 | COL22 | ID3 | COL31 | COL32 |
354-
+-----+-------+-------+-----+-------+-------+-----+-------+-------+
355-
| 2 | 12 | 122 | 2 | 22 | 222 | 2 | 32 | 322 |
356-
| 4 | 14 | 144 | 4 | 24 | 244 | 4 | 34 | 344 |
357-
+-----+-------+-------+-----+-------+-------+-----+-------+-------+
358-
(2 rows)
359-
360-
!ok
361-
362-
!if (use_old_decorr) {
363-
EnumerableHashJoin(condition=[AND(=($0, $6), OR(AND(>($1, 11), <=($7, 32)), AND(<($5, 255), >=($8, 344))))], joinType=[inner])
364-
EnumerableMergeJoin(condition=[AND(=($0, $3), OR(>($1, 11), <($5, 255)))], joinType=[inner])
365-
EnumerableValues(tuples=[[{ 1, 11, 111 }, { 2, 12, 122 }, { 3, 13, 133 }, { 4, 14, 144 }, { 5, 15, 155 }]])
366-
EnumerableValues(tuples=[[{ 1, 21, 211 }, { 2, 22, 222 }, { 3, 23, 233 }, { 4, 24, 244 }, { 5, 25, 255 }]])
367-
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])
368-
EnumerableValues(tuples=[[{ 1, 31, 311 }, { 2, 32, 322 }, { 3, 33, 333 }, { 4, 34, 344 }, { 5, 35, 355 }]])
369-
!plan
370-
!}
371-
372-
!if (use_new_decorr) {
373-
EnumerableMergeJoin(condition=[AND(=($0, $6), OR(AND(>($1, 11), <=($7, 32)), AND(<($5, 255), >=($8, 344))))], joinType=[inner])
374-
EnumerableMergeJoin(condition=[=($0, $3)], joinType=[inner])
375-
EnumerableValues(tuples=[[{ 1, 11, 111 }, { 2, 12, 122 }, { 3, 13, 133 }, { 4, 14, 144 }, { 5, 15, 155 }]])
376-
EnumerableValues(tuples=[[{ 1, 21, 211 }, { 2, 22, 222 }, { 3, 23, 233 }, { 4, 24, 244 }, { 5, 25, 255 }]])
377-
EnumerableValues(tuples=[[{ 1, 31, 311 }, { 2, 32, 322 }, { 3, 33, 333 }, { 4, 34, 344 }, { 5, 35, 355 }]])
378-
!plan
379-
!}
380-
!set planner-rules original
381-
382313
# [CALCITE-7086] Implement a rule that performs the inverse operation of AggregateCaseToFilterRule
383314
# Refer to RelToSqlConverterTest.testAggregateFilterToCase(). The following two SQL
384315
# represent the true filtered Aggregate and the case-style Aggregate converted by AggregateFilterToCaseRule.

0 commit comments

Comments
 (0)