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



##########
File path: 
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/optimizer/Optimizer.scala
##########
@@ -515,10 +515,37 @@ object RemoveRedundantAliases extends Rule[LogicalPlan] {
  * Remove no-op operators from the query plan that do not make any 
modifications.
  */
 object RemoveNoopOperators extends Rule[LogicalPlan] {
+  def resolveOutputAttrName(
+      output: Seq[NamedExpression],
+      projectList: Seq[NamedExpression]): Seq[NamedExpression] = {
+    output.map {
+      case attr: Attribute =>
+        
attr.withName(projectList.find(_.semanticEquals(attr)).getOrElse(attr).name)

Review comment:
       do we need to call `find`? `child.sameOutput(p)` should guarantee that 
the output columns match by position. We just need
   ```
   def restoreOriginalOutputNames(
       projectList: Seq[NamedExpression],
       originalNames: Seq[String]): Seq[NamedExpression] = {
     projectList.zip(originalNames).map {
       case (attr: Attribute, name) => attr.withName(name)
       ...
     }
   }
   ```




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