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



##########
File path: 
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/plans/QueryPlan.scala
##########
@@ -168,6 +170,85 @@ abstract class QueryPlan[PlanType <: QueryPlan[PlanType]] 
extends TreeNode[PlanT
     }.toSeq
   }
 
+
+  /**
+   * Rewrites this plan tree based on the given plan mappings from old plan 
nodes to new nodes.
+   * This method also updates all the related references in this plan tree 
accordingly, in case
+   * the replaced node has different output expr ID than the old node.
+   */
+  def rewriteWithPlanMapping(
+      planMapping: Map[PlanType, PlanType],
+      canGetOutput: PlanType => Boolean = _ => true): PlanType = {
+    def internalRewrite(plan: PlanType): (PlanType, Seq[(Attribute, 
Attribute)]) = {
+      if (planMapping.contains(plan)) {

Review comment:
       you are right, this is a valid use case.




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