gianm commented on a change in pull request #9122: Add SQL GROUPING SETS 
support.
URL: https://github.com/apache/druid/pull/9122#discussion_r384085215
 
 

 ##########
 File path: docs/querying/sql.md
 ##########
 @@ -86,6 +86,22 @@ trigger an aggregation query using one of Druid's [three 
native aggregation quer
 can refer to an expression or a select clause ordinal position (like `GROUP BY 
2` to group by the second selected
 column).
 
+The GROUP BY clause can also refer to multiple grouping sets in three ways. 
The most flexible is GROUP BY GROUPING SETS,
+for example `GROUP BY GROUPING SETS ( (country, city), () )`. This example is 
equivalent to a `GROUP BY country, city`
+followed by `GROUP BY ()` (a grand total). With GROUPING SETS, the underlying 
data is only scanned one time, leading to
+better efficiency. Second, GROUP BY ROLLUP computes a grouping set for each 
level of the grouping expressions. For
+example `GROUP BY ROLLUP (country, city)` is equivalent to `GROUP BY GROUPING 
SETS ( (country, city), (country), () )`
+and will produce grouped rows for each country / city pair, along with 
subtotals for each country, along with a grand
+total. Finally, GROUP BY CUBE computes a grouping set for each combination of 
grouping expressions. For example,
+`GROUP BY CUBE (country, city)` is equivalent to `GROUP BY GROUPING SETS ( 
(country, city), (country), (city), () )`.
+Grouping columns that do not apply to a particular row will contain `NULL`. 
For example, when computing
+`GROUP BY GROUPING SETS ( (country, city), () )`, the grand total row 
corresponding to `()` will have `NULL` for the
+"country" and "city" columns.
+
+When using GROUP BY GROUPING SETS, GROUP BY ROLLUP, or GROUP BY CUBE, be aware 
that results may not be generated in the
 
 Review comment:
   Other paragraphs in this section use plain text for simple keywords and 
preformatted text for examples; see 
https://druid.apache.org/docs/latest/querying/sql.html.
   
   This can be changed but I wanted to keep it consistent in this patch.
   
   What do you think?

----------------------------------------------------------------
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:
[email protected]


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to