AngersZhuuuu commented on a change in pull request #32201: URL: https://github.com/apache/spark/pull/32201#discussion_r618173234
########## File path: docs/sql-ref-syntax-qry-select-groupby.md ########## @@ -95,13 +95,17 @@ aggregate_name ( [ DISTINCT ] expression [ , ... ] ) [ FILTER ( WHERE boolean_ex (product, warehouse, location), (warehouse), (product), (warehouse, product), ())`. The N elements of a `CUBE` specification results in 2^N `GROUPING SETS`. -* **Mixed Grouping Analytics** +* **Mixed/Nested Grouping Analytics** - A GROUP BY clause can include multiple `group_expression`s and multiple `CUBE|ROLLUP|GROUPING SETS`s. + A GROUP BY clause can include multiple `group_expression`s and multiple `CUBE|ROLLUP|GROUPING SETS`s. + `GROUPING SETS` can also have nested `CUBE|ROLLUP|GROUPING SETS` clauses, e.g. + `GROUPING SETS(ROLLUP(warehouse, location), CUBE(warehouse, location))`, + `GROUPING SETS(warehouse, GROUPING SETS(location, GROUPING SETS(ROLLUP(warehouse, location), CUBE(warehouse, location))))`. `CUBE|ROLLUP` is just a syntax sugar for `GROUPING SETS`, please refer to the sections above for how to translate `CUBE|ROLLUP` to `GROUPING SETS`. `group_expression` can be treated as a single-group `GROUPING SETS` under this context. For multiple `GROUPING SETS` in the `GROUP BY` clause, we generate - a single `GROUPING SETS` by doing a cross-product of the original `GROUPING SETS`s. For example, + a single `GROUPING SETS` by doing a cross-product of the original `GROUPING SETS`s. For nested `GROUPING SETS` in the `GROUPING SETS` clause, + we generate a top-level `GROUING SETS` by expand selected grouping sets of nested group elements. For example, Review comment: > It seems your previous example was wrong. > > `GROUPING SETS(GROUPING SETS(a, b), GROUPING SETS(c, d))` should be `GROUPING SETS(a, b, c, d)`, instead of `GROUPING SETS((a, b), (c, d))` Yea, previous example I miss `()`, current is correct. -- 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: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org