cube function
Applies to:  Databricks SQL 
 Databricks Runtime
Creates a multi-dimensional cube using the specified expression columns.
Syntax
cube (expr1 [, ...] )
Arguments
- exprN: Any expression that can be grouped.
Returns
The function must be the only grouping expression in the GROUP BY clause. See GROUP BY clause for details.
Examples
SQL
> SELECT name, age, count(*) FROM VALUES (2, 'Alice'), (5, 'Bob') people(age, name) GROUP BY cube(name, age);
  Bob   5       1
  Alice 2       1
  Alice NULL    1
  NULL  2       1
  NULL  NULL    2
  Bob   NULL    1
  NULL  5       1