allisonwang-db commented on a change in pull request #30659:
URL: https://github.com/apache/spark/pull/30659#discussion_r539001681



##########
File path: 
sql/core/src/main/scala/org/apache/spark/sql/execution/RemoveRedundantProjects.scala
##########
@@ -61,15 +63,24 @@ object RemoveRedundantProjects extends Rule[SparkPlan] {
         val keepOrdering = a.aggregateExpressions
           .exists(ae => ae.mode.equals(Final) || ae.mode.equals(PartialMerge))
         a.mapChildren(removeProject(_, keepOrdering))
-      // GenerateExec requires column ordering since it binds input rows 
directly with its
-      // requiredChildOutput without using child's output schema.
-      case g: GenerateExec => g.mapChildren(removeProject(_, true))
-      // JoinExec ordering requirement will inherit from its parent. If there 
is no ProjectExec in
-      // its ancestors, JoinExec should require output columns to be ordered.
-      case o => o.mapChildren(removeProject(_, requireOrdering))
+      case p if canPassThrough(p) => p.mapChildren(removeProject(_, 
requireOrdering))

Review comment:
       Good question. This is because there might be other nodes that require 
column ordering. An earlier PR also fixed a similar issue for GenerateExec. It 
is safer to use a whitelist in order to prevent similar issues. Most existing 
cases are covered (filter, aggregate and join). We can always add more nodes to 
the whitelist if redundant projects are discovered.




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

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