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


##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/optimizer/Optimizer.scala:
##########
@@ -559,6 +561,34 @@ object RemoveRedundantAliases extends Rule[LogicalPlan] {
         })
         Join(newLeft, newRight, joinType, newCondition, hint)
 
+      case _: Union =>
+        var first = true
+        plan.mapChildren { child =>
+          if (first) {
+            first = false
+            child match {
+              case p: Project =>
+                var passThroughAttributes =
+                  AttributeSet(p.projectList.filter(_.isInstanceOf[Attribute]))

Review Comment:
   I'm not sure this works. The `Project` may not be the direct child of 
`Union`. I think we should add a new bool flag to `removeRedundantAliases` 
which indicates that removing alias should not introduce conflicting expr IDs.



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