AngersZhuuuu commented on a change in pull request #33587:
URL: https://github.com/apache/spark/pull/33587#discussion_r682245766



##########
File path: 
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/optimizer/Optimizer.scala
##########
@@ -518,7 +518,25 @@ object RemoveNoopOperators extends Rule[LogicalPlan] {
   def apply(plan: LogicalPlan): LogicalPlan = plan.transformUpWithPruning(
     _.containsAnyPattern(PROJECT, WINDOW), ruleId) {
     // Eliminate no-op Projects
-    case p @ Project(_, child) if child.sameOutput(p) => child
+    case p @ Project(output, child) if child.sameOutput(p) =>
+      child match {
+        case relation: LeafNode
+          if !output.zip(relation.output).forall { case (a1, a2) => a1.name == 
a2.name } =>
+          p
+        case _ =>
+          val ret = child.transformExpressionsDown {
+            case named: NamedExpression =>

Review comment:
       > I think we need to be explicit here. We can only change the output 
name if `child` has a project list, which is `Project` and `Aggregate`. We 
don't need to handle the general `NamedExpression`, as the project list can 
only be `Attribute` or `Alias`.
   
   Yea, You have explained a point that I am puzzled a lot. How about current.




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