Open hbutani opened 2 years ago
In https://github.com/substrait-io/substrait/pull/240, @guykhazma suggested that this should be considered a function. I'm not convinced that is the case. @hbutani , thoughts?
My two cents: nice to have separate expression types for these like Spark; but I cannot find a reason for them not to be functions.
The standard defines GROUPING
and GROUPING_ID
, which are pretty much synonyms. Oracle also defines GROUP_ID
.
To a first approximation, you can treat them as aggregate functions (in that you can only use them in a GROUP BY
query); their value is constant for the group (i.e. what will become a record emitted from the GROUP BY
) but independent of the actual rows that go into the group.
I think it's overkill to treat them as a special expression type. Aggregate functions will suffice.
ROLLUP
(along with CUBE
, and GROUP BY DISTINCT
) is not really a function but a macro that gives you a shorthand for writing grouping sets. I recommend just supporting GROUPING SETS
.
ROLLUP
(along withCUBE
, andGROUP BY DISTINCT
) is not really a function but a macro that gives you a shorthand for writing grouping sets. I recommend just supportingGROUPING SETS
.
+1. There is a nice explanation of how ROLLUP and CUBE are just shortcuts for GROUPING SETS in the Presto documentation: https://prestodb.io/docs/current/sql/select.html#group-by-clause
For example:
q27
has the expression:group by rollup (i_item_id, s_state)
rank() over (partition by grouping(i_category)+grouping(i_class)..)
Queries in tpcds having this issue:
[27, 36, 86]
How to reproduce: Add a test to
TpcdsQueryNoValidation
like this:On fixing, please move the fixed queries from the
tpcdsFailure
list to thetpcdsSuccess
list