You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@druid.apache.org by GitBox <gi...@apache.org> on 2020/02/26 19:04:46 UTC

[GitHub] [druid] gianm opened a new issue #9410: Add SQL GROUPING, GROUPING_ID functions

gianm opened a new issue #9410: Add SQL GROUPING, GROUPING_ID functions
URL: https://github.com/apache/druid/issues/9410
 
 
   See discussion in https://github.com/apache/druid/pull/9122, especially these comments:
   
   - https://github.com/apache/druid/pull/9122#issuecomment-589828549
   - https://github.com/apache/druid/pull/9122#issuecomment-590652648
   
   It would be good to include GROUPING and GROUPING_ID functions like those documented here: https://docs.microsoft.com/en-us/sql/t-sql/functions/grouping-id-transact-sql?view=sql-server-ver15.
   
   The SQL standard allows them anywhere an aggregation function is allowed:
   
   - SELECT clause, as long as they are not as an input to an aggregation function
   - HAVING clause
   - ORDER BY clause
   
   I think we'd want to expose these as an expression function that is usable in postaggregators. Then havingFilters and limitSpecs could refer to them. This will require some new context being made available to postaggregators that is not currently available (perhaps a virtual field?).
   
   Btw, adding these plus joins on subqueries would allow Calcite's `AggregateExpandDistinctAggregatesRule.INSTANCE` to work properly. It uses those two features to plan queries with exact count distincts on multiple columns (something we currently don't support in Druid SQL, and would be great to support).

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org