Hydra ETL
Build your first job
Hydra DSL5 · TransformationsAggregate
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.

✓ 30 rows → 3 groups

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 by list.
  • Output mapping — A required, non-empty agg mapping.
  • 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.

Aggregate changes row grain to group grain Thirty order rows are grouped by status into three summary rows. 30 ordersrow grain by: statusthree groups 3 summariesgroup grain Grouping decides row identity; reducers decide the attached values.
The output is a different table because its rows mean something different.

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

Close by

0 / 0 on this page