Rollup

Supported in: Batch

Performs the specified aggregations on the input dataset at different levels of granularity, providing both intermediate and super aggregates.

Transform categories: Aggregate

Declared arguments

  • Aggregations - List of aggregations to perform on the dataset.
    List<Expression<AnyType>>
  • Dataset - Dataset to perform rollup on.
    Table
  • Rollup columns - List of columns to rollup the dataset by when aggregating. If empty, no roll up is applied.
    List<Column<AnyType>>

Examples

Example 1: Base case

Argument values:

  • Aggregations: [
    alias(
     alias: max_price,
     expression:
    max(
     expression: price,
    ),
    )]
  • Dataset: ri.foundry.main.dataset.rollupBaseCase
  • Rollup columns: [city]

Input:

citymodelpricestore
Londonnew phone900.0MegaMart
Londonnew phone850.75AA
Londonnew phone870.75ABC Zone
San Francisconew phone1000.0Prescos
San Francisconew phone950.25XZY Force
San Francisconew phone1105.7Phone Mart
LondonforestX 20750.1MegaMart
LondonforestX 20690.0AA
LondonforestX 20730.0ABC Zone
San FranciscoforestX 20890.4Prescos
San FranciscoforestX 20900.1XZY Force
San FranciscoforestX 201050.75Phone Mart

Output:

citymax_price
London900.0
San Francisco1105.7
null1105.7

Example 2: Base case

Argument values:

  • Aggregations: [
    alias(
     alias: mean_price,
     expression:
    mean(
     expression: price,
    ),
    )]
  • Dataset: ri.foundry.main.dataset.rollupBaseCase
  • Rollup columns: [city, model]

Input:

citymodelpricestore
Londonnew phone900.0MegaMart
Londonnew phone850.75AA
Londonnew phone870.75ABC Zone
San Francisconew phone1000.0Prescos
San Francisconew phone950.25XZY Force
San Francisconew phone1105.7Phone Mart
LondonforestX 20750.1MegaMart
LondonforestX 20690.0AA
LondonforestX 20730.0ABC Zone
San FranciscoforestX 20890.4Prescos
San FranciscoforestX 20900.1XZY Force
San FranciscoforestX 201050.75Phone Mart

Output:

citymodelmean_price
Londonnew phone873.8333333333334
LondonforestX 20723.3666666666667
Londonnull798.6
San Francisconew phone1018.65
San FranciscoforestX 20947.0833333333334
San Francisconull982.8666666666667
nullnull890.7333333333335

Example 3: Base case

Argument values:

  • Aggregations: [
    alias(
     alias: max_price,
     expression:
    max(
     expression: plan_prices,
    ),
    )]
  • Dataset: ri.foundry.main.dataset.rollupComplexCase
  • Rollup columns: [model]

Input:

citymodelplan_pricesstores
Londonnew phone[ 900.0, 1080.23, 899.99 ]MegaMart
Londonnew phone[ 850.75, 800.78, 999.99 ]AA
Londonnew phone[ 870.75, 775.0, 804.48 ]ABC Zone
San Francisconew phone[ 910.0, 1030.23, 1100.5 ]Prescos
San Francisconew phone[ 1020.0, 989.99, 1130.0 ]XZY Force
San Francisconew phone[ 1020.0, 1065.25, 1110.99 ]Phone Mart
LondonforestX 20[ 738.5, 701.25, 834.0 ]MegaMart
LondonforestX 20[ 703.75, 821.0, 712.5 ]AA
LondonforestX 20[ 692.0, 787.5, 841.75 ]ABC Zone
San FranciscoforestX 20[ 1003.25, 997.75, 893.5 ]Prescos
San FranciscoforestX 20[ 981.5, 872.25, 1035.0 ]XZY Force
San FranciscoforestX 20[ 928.0, 995.25, 1098.5 ]Phone Mart

Output:

modelmax_price
new phone[ 1020.0, 1065.25, 1110.99 ]
forestX 20[ 1003.25, 997.75, 893.5 ]
null[ 1020.0, 1065.25, 1110.99 ]

Example 4: Null case

Argument values:

  • Aggregations: [
    alias(
     alias: max_price,
     expression:
    max(
     expression: price,
    ),
    )]
  • Dataset: ri.foundry.main.dataset.rollupNullCase
  • Rollup columns: [city, model]

Input:

citymodelpricestores
Londonnew phonenullMegaMart
Londonnew phone850.75AA
Londonnew phone870.75ABC Zone
San Francisconew phonenullPrescos
San Francisconew phonenullXZY Force
San Francisconew phonenullPhone Mart
LondonforestX 20750.1MegaMart
LondonforestX 20690.0AA
LondonforestX 20nullABC Zone
San FranciscoforestX 20890.4Prescos
San FranciscoforestX 20nullXZY Force
San FranciscoforestX 201050.75Phone Mart

Output:

citymodelmax_price
Londonnew phone870.75
LondonforestX 20750.1
Londonnull870.75
San Francisconew phonenull
San FranciscoforestX 201050.75
San Francisconull1050.75
nullnull1050.75

Example 5: Edge case

Argument values:

  • Aggregations: [
    alias(
     alias: mean_price,
     expression:
    mean(
     expression: price,
    ),
    )]
  • Dataset: ri.foundry.main.dataset.rollupBaseCase
  • Rollup columns: []

Input:

citymodelpricestore
Londonnew phone900.0MegaMart
Londonnew phone850.75AA
Londonnew phone870.75ABC Zone
San Francisconew phone1000.0Prescos
San Francisconew phone950.25XZY Force
San Francisconew phone1105.7Phone Mart
LondonforestX 20750.1MegaMart
LondonforestX 20690.0AA
LondonforestX 20730.0ABC Zone
San FranciscoforestX 20890.4Prescos
San FranciscoforestX 20900.1XZY Force
San FranciscoforestX 201050.75Phone Mart

Output:

mean_price
890.7333333333335

Example 6: Edge case

Argument values:

  • Aggregations: [
    alias(
     alias: max_price,
     expression:
    max(
     expression: price,
    ),
    )]
  • Dataset: ri.foundry.main.dataset.rollupEmptyCase
  • Rollup columns: [city, model]

Input:

citymodelpricestore

Output:

citymodelmax_price