You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by GitBox <gi...@apache.org> on 2021/01/13 09:12:06 UTC

[GitHub] [spark] cloud-fan commented on a change in pull request #31145: [SPARK-24081][SQL] Should not pushdown LeftSemi/LeftAnti over Aggregate for some cases

cloud-fan commented on a change in pull request #31145:
URL: https://github.com/apache/spark/pull/31145#discussion_r556367528



##########
File path: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/optimizer/PushDownLeftSemiAntiJoin.scala
##########
@@ -52,9 +52,11 @@ object PushDownLeftSemiAntiJoin extends Rule[LogicalPlan] with PredicateHelper {
       }
 
     // LeftSemi/LeftAnti over Aggregate
-    case join @ Join(agg: Aggregate, rightOp, LeftSemiOrAnti(_), _, _)
-        if agg.aggregateExpressions.forall(_.deterministic) && agg.groupingExpressions.nonEmpty &&
-        !agg.aggregateExpressions.exists(ScalarSubquery.hasCorrelatedScalarSubquery) =>
+    case join @ Join(agg @ Aggregate(groups, aggs, _), rightOp, LeftSemiOrAnti(_), cond, _)
+        if aggs.forall(_.deterministic) && groups.nonEmpty &&
+        !aggs.exists(ScalarSubquery.hasCorrelatedScalarSubquery) &&
+        !(cond.nonEmpty && groups.equals(aggs) &&
+          cond.forall(e => splitConjunctivePredicates(e).forall(_.isInstanceOf[EqualNullSafe]))) =>

Review comment:
       We can add a new method to `JoinSelectionHelper`
   ```
     def canPlanAsBroadcastHashJoin(join: Join, conf: SQLConf): Boolean = {
       getBroadcastBuildSide(join.left, join.right, join.joinType,
         join.hint, hintOnly = true, conf).isDefined ||
       getBroadcastBuildSide(join.left, join.right, join.joinType,
         join.hint, hintOnly = false, conf).isDefined
     }
   ```
   
   and then use it here:
   `if ... && canPlanAsBroadcastHashJoin(join, conf)`




----------------------------------------------------------------
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.

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