maropu commented on a change in pull request #27058: [SPARK-30276][SQL] Support
Filter expression allows simultaneous use of DISTINCT
URL: https://github.com/apache/spark/pull/27058#discussion_r369306575
##########
File path:
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/optimizer/RewriteDistinctAggregates.scala
##########
@@ -148,24 +205,102 @@ object RewriteDistinctAggregates extends
Rule[LogicalPlan] {
val distinctAggs = exprs.flatMap { _.collect {
case ae: AggregateExpression if ae.isDistinct => ae
}}
- // We need at least two distinct aggregates for this rule because
aggregation
- // strategy can handle a single distinct group.
+ // We need at least two distinct aggregates or a single distinct aggregate
with a filter for
+ // this rule because aggregation strategy can handle a single distinct
group without a filter.
// This check can produce false-positives, e.g., SUM(DISTINCT a) &
COUNT(DISTINCT a).
- distinctAggs.size > 1
+ distinctAggs.size >= 1 || distinctAggs.exists(_.filter.isDefined)
Review comment:
not `distinctAggs.size >= 1` but `distinctAggs.size > 1`?
----------------------------------------------------------------
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]
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]