Grammar element · op.aggregate
Aggregate changes the grain
Three valid grouped summaries. The by list defines one output row per group.
transformations.yaml4 steps
What the engine groups
Thirty orders become one output row for each distinct status.
What op.aggregate is
aggregate groups the current rows and computes named summary values at a new grain.
It is not a window calculation: source rows are replaced by one row per distinct by combination.
What it contains
- Grouping keys — A required, non-empty
bylist. - Output mapping — A required, non-empty
aggmapping. - Reducers — Short form reuses a source name; long form separates output, function, and source column.
The by list defines the grain
Read by before reading the functions. It tells you what one output row means; the aggregate mapping then tells you which facts are attached to that row.
Run the complete example
Copy this manifest from the verified documentation project, then run it from the repository root.
version: "1.0"
transformations:
steps:
- cast:
mapping: {amount: float}
- aggregate:
by: [status]
agg:
total_amount: {func: sum, col: amount}
order_count: {func: count, col: order_id}
hdrctl run examples/tutorial/dsl-elements -t aggregate.yaml
✅ Pipeline completed successfully in 4.0s Rows read : 30 Rows written: 3
The relevant command syntax, copied from hdrctl run --help:
hdrctl run [PATH] -s, --sources FILE explicit path to sources.yaml -d, --destinations FILE explicit path to destinations.yaml -t, --transformations FILE explicit path to transformations.yaml -P, --param KEY=VALUE override a parameter, repeatable