AngersZhuuuu commented on a change in pull request #30144:
URL: https://github.com/apache/spark/pull/30144#discussion_r610512769



##########
File path: 
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/grouping.scala
##########
@@ -231,3 +229,30 @@ object GroupingID {
     if (SQLConf.get.integerGroupingIdEnabled) IntegerType else LongType
   }
 }
+
+object GroupingAnalytics {
+  def unapply(exprs: Seq[Expression])
+  : Option[(Seq[Seq[Expression]], Seq[Seq[Expression]], Seq[Expression])] = {
+    if (!exprs.exists(_.find(_.isInstanceOf[BaseGroupingSets]).isDefined)) {
+      None
+    } else {
+      val groups = exprs.flatMap {
+        case gs: BaseGroupingSets => gs.groupByExprs
+        case others: Expression => others :: Nil

Review comment:
       Done

##########
File path: docs/sql-ref-syntax-qry-select-groupby.md
##########
@@ -93,6 +95,38 @@ 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`.
 
+* **Partial Grouping Analytics**
+
+    Partial grouping analytics means there are both `group_expression` and 
`CUBE|ROLLUP|GROUPING SETS`
+    in GROUP BY clause. `CUBE` and `ROLLUP` are just syntax sugar for GROUPING 
SETS, for how to use
+    `CUBE` and `ROLLUP` can refer to the section above about `CUBE` and 
`ROLLUP`. For example:
+    `GROUP BY warehouse, GROUPING SETS((product, location), (product), 
(location), ())` is equivalent to
+    `GROUP BY GROUPING SETS((warehouse, product, location), (warehouse, 
product), (warehouse, location), (warehouse))`.
+    `GROUP BY warehouse, GROUPING SETS((product, location), (producet), ())` 
is equivalent to
+    `GROUP BY GROUPING SETS((warehouse, product, location), (warehouse, 
location), (warehouse))`.
+
+* **Concatenated Grouping Analytics**

Review comment:
       Done

##########
File path: docs/sql-ref-syntax-qry-select-groupby.md
##########
@@ -93,6 +95,38 @@ 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`.
 
+* **Partial Grouping Analytics**
+
+    Partial grouping analytics means there are both `group_expression` and 
`CUBE|ROLLUP|GROUPING SETS`
+    in GROUP BY clause. `CUBE` and `ROLLUP` are just syntax sugar for GROUPING 
SETS, for how to use

Review comment:
       Done




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