GitHub user hvanhovell opened a pull request:
https://github.com/apache/spark/pull/15187
[SPARK-17616][SQL] Support a single distinct aggregate combined with a
non-partial aggregate
## What changes were proposed in this pull request?
We currently cannot execute an aggregate that contains a single distinct
aggregate function and an one or more non-partially plannable aggregate
functions, for example:
```sql
select grp,
collect_list(col1),
count(distinct col2)
from tbl_a
group by 1
```
This is a regression from Spark 1.6. This is caused by the fact that the
single distinct aggregation code path assumes that all aggregates can be
planned in two phases (is partially aggregatable). This PR works around this
issue by triggering the `RewriteDistinctAggregates` in such cases (this is
similar to the approach taken in 1.6).
## How was this patch tested?
Created `RewriteDistinctAggregatesSuite` which checks if the aggregates
with distinct aggregate functions get rewritten into two `Aggregates` and an
`Expand`. Added a regression test to `DataFrameAggregateSuite`.
You can merge this pull request into a Git repository by running:
$ git pull https://github.com/hvanhovell/spark SPARK-17616
Alternatively you can review and apply these changes as the patch at:
https://github.com/apache/spark/pull/15187.patch
To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:
This closes #15187
----
commit 4a9ffaacac03070aa64baeb0a0e3b00d40865491
Author: Herman van Hovell <[email protected]>
Date: 2016-09-21T22:11:56Z
Add case to RewriteDistinctAggregates to rewrite a single distinct
aggregate combined with a non-partial aggregate.
----
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]