You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by "wankunde (via GitHub)" <gi...@apache.org> on 2023/05/31 08:52:42 UTC

[GitHub] [spark] wankunde commented on a diff in pull request #39908: [SPARK-42360][SQL] Transform LeftOuter join with IsNull filter on right side to Anti join

wankunde commented on code in PR #39908:
URL: https://github.com/apache/spark/pull/39908#discussion_r1111138117


##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/optimizer/joins.scala:
##########
@@ -204,6 +204,26 @@ object EliminateOuterJoin extends Rule[LogicalPlan] with PredicateHelper {
 
   def apply(plan: LogicalPlan): LogicalPlan = plan.transformWithPruning(
     _.containsPattern(OUTER_JOIN), ruleId) {
+    case p @ Project(projectList, Filter(cond, j @ Join(left, right, LeftOuter, _, _)))
+        if projectList.forall(canEvaluate(_, left)) =>
+      val notNullAttrs =
+        AttributeSet(right.constraints.collect { case IsNotNull(a: Attribute) => a })
+      if (notNullAttrs.nonEmpty) {
+        val (isNullConditions, rest) = splitConjunctivePredicates(cond).partition {
+          case IsNull(a: Attribute) => notNullAttrs.contains(a)
+          case _ => false
+        }
+        if (isNullConditions.nonEmpty &&
+          rest.forall(_.references.intersect(right.outputSet).isEmpty)) {

Review Comment:
   Thanks @wangyum , I have updated the UT.



-- 
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-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org