Group By
Aggregates groups of rows into a single row
Processing
The step calculates group fields for each row, and aggregates values per group.
Mode
The mode to use:
- one aggregate row per group generates one summary row per group
- keep all rows, add rolling aggregate to each row passes through all input rows immediately, attaches partial aggregate
- keep all rows, add complete aggregate to each row caches each group’s input rows and outputs them once the group is complete - attaches full group aggregate value to each row
Group By
Defines the grouping of rows.
Evaluated for each input row
- Type
- Data type of the grouping field. Values are implicitly cast to this type.
- Name
- Name of the grouping field.
- Value
- Value of the grouping field.
Settings
Name | Type | Description |
---|---|---|
Collated Groups |
boolean |
This step can optimize row output and memory consumption if it is guaranteed that incoming rows are sorted by group fields.
Evaluated once when step initializes |
Aggregate
Defines aggregated fields for each group.
- Type
- Type of the field. Final aggregated value is cast to this type.
- Name
- Name of the field.
- Aggregation
- Evaluated once when step initializes
You can specify an aggregator in the following ways:- Use one of the aggregators available in the morph context menu.
- Supply a function
(a, x) -> any
that receives the current aggregate value asa
, and the subject to aggregate asx
. The function returns the new aggregate value. When invoked for the first time per group,a
isnil
. - Supply a dict with the following keys:
init
(optional) initial aggregation state.nil
is implied if omitted.acc
aggregation function(a, x) -> any
that receives the current aggregation statea
and the subject to aggregate asx
and returns the new aggregation state.out
(optional) function(a) -> any
that receives the current aggregation state and returns the aggregation value to place in the aggregation field.(a) -> a
is implied if omitted.
- Subject
- Evaluated for each input row
The subject to aggregate.
Results
Name | Type | Description |
---|---|---|
group |
dict | Current grouping variables. |