improve grouping_distribution() to consider all grouping keys
The original implementation required the distribution expression
to match the first grouping key, which resulted in suprising
inconsistencies when pushing down aggregation.
For example consider table 't' distributed by column 'a'
CREATE TABLE t (a int, b int, c int) DISTRIBUTED BY (a);
and queries
SELECT a, b, COUNT(*) FROM t GROUP BY a, b;
SELECT b, a, COUNT(*) FROM t GROUP BY b, a;
Those queries are by definition equivalent, but the planner
used the full push-down only for the first one, as it has 'a'
as the first grouping key. The second query was using 2-phase
aggregation unnecessarily.