amplab/shark — pull request #220 by harveyfeng (2013-12-01 22:52:03+00:00)
Title: AST transformations for DISTINCT aggregates

Splits DISTINCT aggregates into two shuffles: the first to hash-partition selected expressions and the second to rendezvous at a single reducer that will do the final aggregation.

The general structure for a SQL rewrite is:
```
SELECT (DISTINCT ) FROM
```
gets transformed into
```
SELECT (*) FROM
(SELECT DISTINCT FROM )
```
where is a table, subquery, or a table or subquery alias.