Skip to content

Commit d98bc35

Browse files
committed
Update FilterPushdownSuite.scala
1 parent fa65718 commit d98bc35

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/optimizer/FilterPushdownSuite.scala

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ class FilterPushdownSuite extends PlanTest {
3333
val batches =
3434
Batch("Subqueries", Once,
3535
EliminateSubQueries) ::
36+
Batch("Transform Condition", Once,
37+
TransformCondition) ::
3638
Batch("Filter Pushdown", Once,
3739
CombineFilters,
3840
PushPredicateThroughProject,
@@ -197,6 +199,26 @@ class FilterPushdownSuite extends PlanTest {
197199

198200
comparePlans(optimized, correctAnswer)
199201
}
202+
203+
test("joins: push to one side after transformCondition") {
204+
val x = testRelation.subquery('x)
205+
val y = testRelation1.subquery('y)
206+
207+
val originalQuery = {
208+
x.join(y, Inner)
209+
.where(("x.a".attr === 1 && "y.d".attr === "x.b".attr) ||
210+
("x.a".attr === 1 && "y.d".attr === "x.c".attr))
211+
}
212+
213+
val optimized = Optimize.execute(originalQuery.analyze)
214+
val left = testRelation.where('a === 1)
215+
val right = testRelation1
216+
val correctAnswer =
217+
left.join(right, condition = Some("d".attr === "b".attr || "d".attr === "c".attr)).analyze
218+
219+
comparePlans(optimized, correctAnswer)
220+
}
221+
200222

201223
test("joins: rewrite filter to push to either side") {
202224
val x = testRelation.subquery('x)

0 commit comments

Comments
 (0)