Skip to content

GroupingSets Unary Logical Operator

GroupingSets is a BaseGroupingSets that represents the following high-level SQL-only operators (in a logical query plan):

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 is created using apply utility only.

Creating GroupingSets

apply(
  groupingSets: Seq[Seq[Expression]]): GroupingSets // (1)!
apply(
  groupingSets: Seq[Seq[Expression]],
  userGivenGroupByExprs: Seq[Expression]): GroupingSets
  1. userGivenGroupByExprs is an empty collection (Nil)

apply computes the GroupingSet indicies and creates a GroupingSets.


apply is used when: