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



##########
File path: 
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/optimizer/PropagateEmptyRelation.scala
##########
@@ -137,3 +125,55 @@ object PropagateEmptyRelation extends Rule[LogicalPlan] 
with PredicateHelper wit
     }
   }
 }
+
+/**
+ * This rule runs in the normal optimizer and optimizes more cases
+ * compared to [[PropagateEmptyRelationBase]]:
+ * 1. Higher-node Logical Plans
+ *    - Union with all empty children.
+ * 2. Unary-node Logical Plans
+ *    - Project/Filter/Sample with all empty children.
+ *
+ * The reason why we don't apply this rule at AQE optimizer side is: the 
benefit is not big enough
+ * and it may introduce extra exchanges.

Review comment:
       After more thought, I think this is a big performance issue if we can't 
propagate empty relations through project/filter which are quite common. The 
risk of introducing new shuffles is relatively small compared to this.
   
   @ulysses-you can we move all the logic to `PropagateEmptyRelationBase`? 
`PropagateEmptyRelation` should not have any extra logic.




-- 
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: reviews-unsubscr...@spark.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org

Reply via email to