GroupingSets Unary Logical Operator¶
GroupingSets is a BaseGroupingSets that represents the following high-level SQL-only operators (in a logical query plan):
- GROUPING SETS SQL statement
- GROUP BY ... GROUPING SETS SQL statement
Note
grouping and grouping_id standard functions can only be used with grouping analytics clauses (incl. GroupingSets).
Spark Structured Streaming Not Supported
Grouping Sets is not supported on streaming DataFrames (that is enforced by UnsupportedOperationChecker).
Creating Instance¶
GroupingSets takes the following to be created:
- GroupingSets Indicies
- Flat GroupingSets Expressions
- User-Specified GroupBy Expressions
GroupingSets is created using apply utility only.
Creating GroupingSets¶
apply(
  groupingSets: Seq[Seq[Expression]]): GroupingSets // (1)!
apply(
  groupingSets: Seq[Seq[Expression]],
  userGivenGroupByExprs: Seq[Expression]): GroupingSets
- userGivenGroupByExprsis an empty collection (- Nil)
apply computes the GroupingSet indicies and creates a GroupingSets.
apply is used when:
- AstBuilderis requested to parse GROUPING SETS or GROUP BY ... GROUPING SETS SQL statements