ulysses-you commented on a change in pull request #32816:
URL: https://github.com/apache/spark/pull/32816#discussion_r692653369



##########
File path: 
sql/core/src/main/scala/org/apache/spark/sql/execution/adaptive/AdaptiveSparkPlanExec.scala
##########
@@ -656,13 +687,54 @@ case class AdaptiveSparkPlanExec(
     // node to prevent the loss of the `BroadcastExchangeExec` node in DPP 
subquery.
     // Here, we also need to avoid to insert the `BroadcastExchangeExec` node 
when the newPlan
     // is already the `BroadcastExchangeExec` plan after apply the 
`LogicalQueryStageStrategy` rule.
-    val finalPlan = currentPhysicalPlan match {
+    def updateBroadcastExchange(plan: SparkPlan): SparkPlan = 
currentPhysicalPlan match {
       case b: BroadcastExchangeLike
-        if (!newPlan.isInstanceOf[BroadcastExchangeLike]) => 
b.withNewChildren(Seq(newPlan))
-      case _ => newPlan
+        if (!plan.isInstanceOf[BroadcastExchangeLike]) => 
b.withNewChildren(Seq(plan))
+      case _ => plan
     }
 
-    (finalPlan, optimized)
+    val optimizedWithSkewedJoin = applyPhysicalRules(
+      optimizedPhysicalPlan,
+      optimizeSkewedJoinWithExtraShuffleRules,
+      Some((planChangeLogger, "AQE Optimize Skewed Join With Extra Shuffle"))
+    )
+    val validatedWithSkewedJoin =
+      checkDistribution(
+        optimizedWithSkewedJoin,
+        optimizedPhysicalPlan,
+        isFinalStage(optimizedWithSkewedJoin),

Review comment:
       Since `OptimizeSkewedJoin` moved to preparation phase, we need to 
validate if it change the output partitioning in final stage. Otherwise, the we 
may not satisfy `requiredDistribution` if `OptimizeSkewedJoin` applied.




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

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