@@ -22,6 +22,7 @@ import org.apache.spark.sql.catalyst.plans.Inner
2222import org .apache .spark .sql .catalyst .plans .FullOuter
2323import org .apache .spark .sql .catalyst .plans .LeftOuter
2424import org .apache .spark .sql .catalyst .plans .RightOuter
25+ import org .apache .spark .sql .catalyst .plans .LeftSemi
2526import org .apache .spark .sql .catalyst .plans .logical ._
2627import org .apache .spark .sql .catalyst .rules ._
2728import org .apache .spark .sql .catalyst .types ._
@@ -303,13 +304,13 @@ object PushPredicateThroughJoin extends Rule[LogicalPlan] with PredicateHelper {
303304
304305 (leftFilterConditions ++ commonFilterCondition).
305306 reduceLeftOption(And ).map(Filter (_, newJoin)).getOrElse(newJoin)
306- case LeftOuter =>
307+ case _ @ ( LeftOuter | LeftSemi ) =>
307308 // push down the left side only `where` condition
308309 val newLeft = leftFilterConditions.
309310 reduceLeftOption(And ).map(Filter (_, left)).getOrElse(left)
310311 val newRight = right
311312 val newJoinCond = joinCondition
312- val newJoin = Join (newLeft, newRight, LeftOuter , newJoinCond)
313+ val newJoin = Join (newLeft, newRight, joinType , newJoinCond)
313314
314315 (rightFilterConditions ++ commonFilterCondition).
315316 reduceLeftOption(And ).map(Filter (_, newJoin)).getOrElse(newJoin)
@@ -339,14 +340,14 @@ object PushPredicateThroughJoin extends Rule[LogicalPlan] with PredicateHelper {
339340 val newJoinCond = (rightJoinConditions ++ commonJoinCondition).reduceLeftOption(And )
340341
341342 Join (newLeft, newRight, RightOuter , newJoinCond)
342- case LeftOuter =>
343+ case _ @ ( LeftOuter | LeftSemi ) =>
343344 // push down the right side only join filter for right sub query
344345 val newLeft = left
345346 val newRight = rightJoinConditions.
346347 reduceLeftOption(And ).map(Filter (_, right)).getOrElse(right)
347348 val newJoinCond = (leftJoinConditions ++ commonJoinCondition).reduceLeftOption(And )
348349
349- Join (newLeft, newRight, LeftOuter , newJoinCond)
350+ Join (newLeft, newRight, joinType , newJoinCond)
350351 case FullOuter => f
351352 }
352353 }
0 commit comments