tanelk commented on a change in pull request #30018:
URL: https://github.com/apache/spark/pull/30018#discussion_r508964832



##########
File path: 
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/optimizer/Optimizer.scala
##########
@@ -477,6 +478,25 @@ object RemoveRedundantAliases extends Rule[LogicalPlan] {
   def apply(plan: LogicalPlan): LogicalPlan = removeRedundantAliases(plan, 
AttributeSet.empty)
 }
 
+/**
+ * Remove redundant aggregates from a query plan. A redundant aggregate is an 
aggregate whose
+ * only goal is to keep distinct values, while its parent aggregate would 
ignore duplicate values.
+ */
+object RemoveRedundantAggregates extends Rule[LogicalPlan] {
+  def apply(plan: LogicalPlan): LogicalPlan = plan transformUp {

Review comment:
       I meant that `lowerIsRedundant(A1, A2)` would return true, If it would 
return false, then A2 would not be removed at all.
   
   With `transformDown` it would check `A1` and `A2` and remove `A2`, but then 
it would not check `A1` and `A3` on the same iteration.




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