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


##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/optimizer/Optimizer.scala:
##########
@@ -552,13 +581,28 @@ object RemoveRedundantAliases extends Rule[LogicalPlan] {
         val newLeft = removeRedundantAliases(left, excluded ++ right.outputSet)
         val newRight = removeRedundantAliases(right, excluded ++ 
newLeft.outputSet)
         val mapping = AttributeMap(
-          createAttributeMapping(left, newLeft) ++
-          createAttributeMapping(right, newRight))
-        val newCondition = condition.map(_.transform {
-          case a: Attribute => mapping.getOrElse(a, a)
-        })
+          createAttributeMapping(left, newLeft) ++ 
createAttributeMapping(right, newRight))
+        val newCondition = condition.map(mapAttribute(_, mapping))
         Join(newLeft, newRight, joinType, newCondition, hint)
 
+      case p: Project =>
+        val newChild = removeRedundantAliases(p.child, excluded)
+        val mapping = AttributeMap(createAttributeMapping(p.child, newChild))
+        Project(removeRedundantAliases(mapAttributes(p.projectList, mapping), 
excluded), newChild)
+
+      case a: Aggregate =>
+        val newChild = removeRedundantAliases(a.child, excluded)
+        val mapping = AttributeMap(createAttributeMapping(a.child, newChild))
+        Aggregate(mapAttributes(a.groupingExpressions, mapping),
+          removeRedundantAliases(mapAttributes(a.aggregateExpressions, 
mapping), excluded),
+          newChild)
+
+      case w: Window =>

Review Comment:
   why do we need to deal with these 3 nodes separately now?



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