Thanks! I'll take a look at building on your work. I'm not very familiar
with Maven; how can I set up the Drill build to use a custom version of
Calcite?

Michael

On Sun, Nov 9, 2014 at 11:15 AM, Julian Hyde <[email protected]> wrote:

> FYI, I've started work on CALCITE-370 in branch
> https://github.com/julianhyde/incubator-calcite/tree/calcite-370. I've
> only done the parser changes so far; I haven't changed the relational
> algebra.
>
> My plan is to generalize the Aggregate class to have a list of grouping
> sets. If you use simple GROUP BY x, y you will get just one grouping set as
> if you had written GROUP BY GROUPING SETS (x, y). The output row type will
> include indicator columns, one for each distinct grouping expression (see
> the GROUPING function,
> https://docs.oracle.com/cd/B19306_01/server.102/b14223/aggreg.htm#i1007434
> ).
>
> public class Aggregate extends SingleRel {
>   public final BitSet groupKey;
>   public final List<BitSet> groupSets;
>   public final GroupingType groupingType;
>
>   enum GroupingType {
>     SINGLE, // one grouping set
>     ROLLUP, // roll up leading edge: (x, y, z), (x, y), (x), ()
>     CUBE, // the full 2^n grouping sets
>     OTHER // not one of the above
> }
>
> The row type for 'select k0, k1, sum(c) as a0, sum(d) as a1, sum(e) as a2
> from t group k0, k1' would be (k0, g0, k1, g1, a0, a1, a2). Note the
> indicator columns g0, g1. g0 evaluates GROUPING(k0), saying whether this
> row is a roll up over all g0 values.
>
> Existing rules will have to be changed to only fire if groupingType ==
> SINGLE, and skip over the indicator columns.
>
> Julian

Reply via email to