Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1457,8 +1457,9 @@ object PushPredicateThroughJoin extends Rule[LogicalPlan] with PredicateHelper {
val (pushDownCandidates, nonDeterministic) = condition.partition(_.deterministic)
val (leftEvaluateCondition, rest) =
pushDownCandidates.partition(_.references.subsetOf(left.outputSet))
val (rightEvaluateCondition, commonCondition) =
rest.partition(expr => expr.references.subsetOf(right.outputSet))
val (rightEvaluateCondition, _) =
pushDownCandidates.partition(_.references.subsetOf(right.outputSet))
val commonCondition = rest.filterNot(e => rightEvaluateCondition.exists(_.semanticEquals(e)))

(leftEvaluateCondition, rightEvaluateCondition, commonCondition ++ nonDeterministic)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1384,4 +1384,14 @@ class FilterPushdownSuite extends PlanTest {
condition = Some("x.a".attr === "z.a".attr)).analyze
comparePlans(optimized, correctAnswer)
}

test("SPARK-28220: Push down the foldable predicate to both sides of Join") {
val x = testRelation.subquery('x)
val y = testRelation.subquery('y)
val originalQuery = x.join(y, condition = Some(false))

val optimized = Optimize.execute(originalQuery.analyze)
val correctAnswer = x.where(false).join(y.where(false), condition = None).analyze
comparePlans(optimized, correctAnswer.analyze)
}
}