@@ -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
0 commit comments