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



##########
File path: 
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/optimizer/RemoveRedundantAggregates.scala
##########
@@ -67,4 +67,8 @@ object RemoveRedundantAggregates extends Rule[LogicalPlan] 
with AliasHelper {
 
     upperHasNoDuplicateSensitiveAgg && upperRefsOnlyDeterministicNonAgg
   }
+
+  private def isDuplicateSensitive(ae: AggregateExpression): Boolean = {
+    !ae.isDistinct && 
!EliminateDistinct.isDuplicateAgnostic(ae.aggregateFunction)

Review comment:
       That would break `EliminateDistinct`.
   
   `EliminateDistinct.isDuplicateAgnostic` checks if it could remove distinct 
from the `AggregateExpression`.
   Currently it is "if the `af` is `max`, `min`.. , then remove `isDistinct`. 
Your proposition would change it to "if `ae` has `isDistinct`, then remove 
`isDistinct`.
   

##########
File path: 
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/optimizer/RemoveRedundantAggregates.scala
##########
@@ -67,4 +67,8 @@ object RemoveRedundantAggregates extends Rule[LogicalPlan] 
with AliasHelper {
 
     upperHasNoDuplicateSensitiveAgg && upperRefsOnlyDeterministicNonAgg
   }
+
+  private def isDuplicateSensitive(ae: AggregateExpression): Boolean = {
+    !ae.isDistinct && 
!EliminateDistinct.isDuplicateAgnostic(ae.aggregateFunction)

Review comment:
       That would break `EliminateDistinct`.
   
   `EliminateDistinct.isDuplicateAgnostic` checks if it could remove distinct 
from the `AggregateExpression`.
   Currently it is "if the `af` is `max`, `min`.. , then remove `isDistinct`. 
Your proposition would change it to "if `ae` has `isDistinct`, then remove 
`isDistinct`".
   




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