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


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

  groupingSets: Seq[Seq[Expression]]): GroupingSets // (1)!
  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: