This enables groupin sets path by removing the elog(ERROR, ...) from
transformGroupClause(). The paths are currently considered as not
eligible for push-down, irrespectedly of the distribution.
This could be improved by enabling pushdown if all the grouping sets
are compatible with the distribution (as if each grouping set was
a separate GROUP BY clause). So for example assuming a table 't'
distributed by column 'a', we could push down these grouping sets
GROUP BY GROUPING SETS ((a), (a, b), (a, c))
but not
GROUP BY GROUPING SETS ((b), (a, b), (a, c))
because the first grouping set does not contain the distribution key.
The grouping sets require sorted paths, so we get paths like this:
SELECT a, b, COUNT(c) FROM t GROUP BY GROUPING SETS ((a), (a, b));
QUERY PLAN
---------------------------------------------
GroupAggregate
Group Key: a, b
Group Key: a
-> Remote Subquery Scan on all (dn1,dn2)
-> Sort
Sort Key: a, b
-> Seq Scan on t2
(7 rows)
There's however a bug somewhere (likely in fix_upper_expr or elsewhere
in setrefs.c), resulting in failures like this:
SELECT a, b, COUNT(c) FROM t GROUP BY GROUPING SETS ((a), (b));
ERROR: variable not found in subplan target list
The only difference between the queries is removal of the distribution
key from the second grouping set.
/* only called when constructing grouping paths */
Assert(parse->groupingSets || parse->hasAggs || parse->groupClause);
- /* grouping sets are currently disabled */
+ /* push-down of grouping sets is not supported yet */
if (parse->groupingSets)
return false;
case GROUPING_SET_SETS:
case GROUPING_SET_CUBE:
case GROUPING_SET_ROLLUP:
- ereport(ERROR,
- (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
- errmsg("GROUPING SETS, ROLLUP or CUBE is not yet supported")));
gsets = lappend(gsets,
transformGroupingSet(&result,
pstate, gset,