maropu commented on a change in pull request #32201:
URL: https://github.com/apache/spark/pull/32201#discussion_r616250742



##########
File path: docs/sql-ref-syntax-qry-select-groupby.md
##########
@@ -24,8 +24,8 @@ license: |
 The `GROUP BY` clause is used to group the rows based on a set of specified 
grouping expressions and compute aggregations on
 the group of rows based on one or more specified aggregate functions. Spark 
also supports advanced aggregations to do multiple
 aggregations for the same input record set via `GROUPING SETS`, `CUBE`, 
`ROLLUP` clauses.
-The grouping expressions and advanced aggregations can be mixed in the `GROUP 
BY` clause.
-See more details in the `Mixed Grouping Analytics` section. When a FILTER 
clause is attached to
+The grouping expressions and advanced aggregations can be mixed in the `GROUP 
BY` clause and nested in `GROUPING SETS` clause.

Review comment:
       nested in `GROUPING SETS` clause. => nested in a `GROUPING SETS` clause.

##########
File path: 
sql/core/src/test/resources/sql-tests/results/ansi/group-analytics.sql.out
##########
@@ -1067,3 +1067,227 @@ struct<a:int,b:int,count(1):bigint>
 3      NULL    2
 3      NULL    2
 3      NULL    2
+
+
+-- !query
+SELECT a, b, count(1) FROM testData GROUP BY a, GROUPING SETS(ROLLUP(a, b))

Review comment:
       NOTE: Just in case, I've checked all the results here are the same with 
PostgreSQL ones.

##########
File path: sql/core/src/test/resources/sql-tests/inputs/group-analytics.sql
##########
@@ -80,3 +80,14 @@ SELECT a, b, count(1) FROM testData GROUP BY a, GROUPING 
SETS((a, b), (a), ());
 SELECT a, b, count(1) FROM testData GROUP BY a, CUBE(a, b), GROUPING SETS((a, 
b), (a), ());
 SELECT a, b, count(1) FROM testData GROUP BY a, CUBE(a, b), ROLLUP(a, b), 
GROUPING SETS((a, b), (a), ());
 
+-- Support use CUBE/ROLLUP/GROUPING SETS in GROUPING SETS

Review comment:
       use -> nested?

##########
File path: 
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/parser/AstBuilder.scala
##########
@@ -1022,6 +1003,38 @@ class AstBuilder extends SqlBaseBaseVisitor[AnyRef] with 
SQLConfHelper with Logg
     }
   }
 
+  private def resolveGroupingAnalytics(

Review comment:
       resolveGroupingAnalytics -> visitGroupingAnalytics

##########
File path: docs/sql-ref-syntax-qry-select-groupby.md
##########
@@ -95,9 +95,12 @@ 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.
+    Also `GROUPING SETS` can have nested `CUBE|ROLLUP|GROUPING SETS` clauses, 
e.g.

Review comment:
       nit: Also `GROUPING SETS` can have => `GROUPING SETS` can also have?




-- 
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]



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

Reply via email to