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:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to