cloud-fan commented on code in PR #36530: URL: https://github.com/apache/spark/pull/36530#discussion_r873346931
########## sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/optimizer/joins.scala: ########## @@ -211,6 +219,15 @@ object EliminateOuterJoin extends Rule[LogicalPlan] with PredicateHelper { if projectList.forall(_.deterministic) && p.references.subsetOf(right.outputSet) && allDuplicateAgnostic(aggExprs) => a.copy(child = p.copy(child = right)) + + case p @ Project(_, ExtractEquiJoinKeys(LeftOuter, _, rightKeys, _, _, left, right, _)) + if right.distinctKeys.exists(_.subsetOf(ExpressionSet(rightKeys))) && + p.references.subsetOf(left.outputSet) => + p.copy(child = left) Review Comment: For a left outer join with only left-side columns being selected, the join can only change the result if we can find more than one matched row on the right side. If the right side join keys are unique, apparently we can't find more than one match. So this optimization LGTM. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org