@@ -36,6 +36,7 @@ class FilterPushdownSuite extends PlanTest {
36
36
Batch (" Filter Pushdown" , Once ,
37
37
CombineFilters ,
38
38
PushPredicateThroughProject ,
39
+ BooleanSimplification ,
39
40
PushPredicateThroughJoin ,
40
41
PushPredicateThroughGenerate ,
41
42
ColumnPruning ,
@@ -156,11 +157,9 @@ class FilterPushdownSuite extends PlanTest {
156
157
.where(' a === 1 && ' a === 2 )
157
158
.select(' a ).analyze
158
159
159
-
160
160
comparePlans(optimized, correctAnswer)
161
161
}
162
162
163
-
164
163
test(" joins: push to either side" ) {
165
164
val x = testRelation.subquery(' x )
166
165
val y = testRelation.subquery(' y )
@@ -198,6 +197,25 @@ class FilterPushdownSuite extends PlanTest {
198
197
comparePlans(optimized, correctAnswer)
199
198
}
200
199
200
+ test(" joins: push to one side after transformCondition" ) {
201
+ val x = testRelation.subquery(' x )
202
+ val y = testRelation1.subquery(' y )
203
+
204
+ val originalQuery = {
205
+ x.join(y)
206
+ .where((" x.a" .attr === 1 && " y.d" .attr === " x.b" .attr) ||
207
+ (" x.a" .attr === 1 && " y.d" .attr === " x.c" .attr))
208
+ }
209
+
210
+ val optimized = Optimize .execute(originalQuery.analyze)
211
+ val left = testRelation.where(' a === 1 )
212
+ val right = testRelation1
213
+ val correctAnswer =
214
+ left.join(right, condition = Some (" d" .attr === " b" .attr || " d" .attr === " c" .attr)).analyze
215
+
216
+ comparePlans(optimized, correctAnswer)
217
+ }
218
+
201
219
test(" joins: rewrite filter to push to either side" ) {
202
220
val x = testRelation.subquery(' x )
203
221
val y = testRelation.subquery(' y )
@@ -563,17 +581,16 @@ class FilterPushdownSuite extends PlanTest {
563
581
// push down invalid
564
582
val originalQuery1 = {
565
583
x.select(' a , ' b )
566
- .sortBy(SortOrder (' a , Ascending ))
567
- .select(' b )
584
+ .sortBy(SortOrder (' a , Ascending ))
585
+ .select(' b )
568
586
}
569
587
570
588
val optimized1 = Optimize .execute(originalQuery1.analyze)
571
589
val correctAnswer1 =
572
590
x.select(' a , ' b )
573
- .sortBy(SortOrder (' a , Ascending ))
574
- .select(' b ).analyze
591
+ .sortBy(SortOrder (' a , Ascending ))
592
+ .select(' b ).analyze
575
593
576
594
comparePlans(optimized1, analysis.EliminateSubQueries (correctAnswer1))
577
-
578
595
}
579
596
}
0 commit comments