maryannxue commented on a change in pull request #29134:
URL: https://github.com/apache/spark/pull/29134#discussion_r456200591



##########
File path: 
sql/core/src/main/scala/org/apache/spark/sql/execution/adaptive/AdaptiveSparkPlanExec.scala
##########
@@ -374,12 +374,14 @@ case class AdaptiveSparkPlanExec(
   }
 
   private def newQueryStage(e: Exchange): QueryStageExec = {
-    val optimizedPlan = applyPhysicalRules(e.child, queryStageOptimizerRules)
+    // apply optimizer rules to the Exchange node and its children, allowing 
plugins to be
+    // able to replace the Exchange node itself
+    val optimizedPlan = applyPhysicalRules(e, queryStageOptimizerRules)

Review comment:
       I think it's safer to use `s.withNewChildren(optimizedChildPlan)` than 
adding special handling in those physical rules: 
https://github.com/apache/spark/pull/29134/files#diff-a30c7a6fcdcdd13e57135fd04d05f3b7R115-R117
   
   That saves you the trouble of worrying about certain assumptions being 
broken in an arbitrary rule.




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