cloud-fan commented on code in PR #45134:
URL: https://github.com/apache/spark/pull/45134#discussion_r1492014338


##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/optimizer/RewriteWithExpression.scala:
##########
@@ -41,10 +41,15 @@ object RewriteWithExpression extends Rule[LogicalPlan] {
           rewriteWithExprAndInputPlans(expr, inputPlans)
         }
         newPlan = newPlan.withNewChildren(inputPlans.toIndexedSeq)
-        if (p.output == newPlan.output) {
-          newPlan
-        } else {
+        // Since we add extra Projects with extra columns to pre-evaluate the 
common expressions,
+        // the current operator may have extra columns if it inherits the 
output columns from its
+        // child, and we need to project away the extra columns to keep the 
plan schema unchanged.

Review Comment:
   not related to this PR but refine the code here since I'm touching this 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.

To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org

Reply via email to