Transforms
Transforms change rows. Each transform reads from a build (or another transform via SQL) and either applies a list of steps in order, or runs a single SQL query - never both.
Each step receives the frame produced by the one before it, in the order you list them. A SQL transform replaces from + steps with a single query.
At a glance
- Steps or SQL, never both - list
stepsin order, or give a singlequery. - Row-wise and stateful steps -
filter,select,rename,cast,derive,add_timestamp, plusaggregate,forward_fill,gap_fill. - State is safe - stateful results commit only after every destination succeeds.
Common shape
Code
Step types
Row-wise steps
| Step | Purpose | Key fields |
|---|---|---|
filter | Keep matching rows | filter_expr |
select | Keep a set of columns | columns |
rename | Rename columns | columns (from/to) |
cast | Change column types | columns (name/type) |
derive | New columns from SQL expressions | columns (name/expr) |
add_timestamp | Add ingestion timestamps | columns (default ingested_at) |
Ordered and stateful steps
| Step | Purpose | Key fields |
|---|---|---|
aggregate | Group-by aggregations | columns, group_by |
forward_fill | Carry last value forward | order_by, partition_by, columns |
gap_fill | Generate missing rows | sequence |
aggregate, forward_fill, and gap_fill can keep state across runs - see Stateful transforms.
Reference by step
Every field, type, default, and required marker is listed per step:
| Step | Reference |
|---|---|
filter | filter |
select | select |
rename | rename |
cast | cast |
derive | derive |
add_timestamp | add_timestamp |
aggregate | aggregate |
forward_fill | forward_fill |
gap_fill | gap_fill |
Steps in detail
filter
Any Spark SQL expression; simple column op value comparisons are auto-normalized:
Code
select, rename, cast, derive
Code
derive accepts any Spark SQL expression (amount * qty, upper(name), concat(a, '-', b), CASE expressions, …).
add_timestamp
Adds current_timestamp() columns - defaults to a single ingested_at column when columns is empty.
aggregate
Code
Grammar: any Spark SQL aggregate works for plain batch and windowed streaming aggregates (sum(price*qty), stddev, collect_set, …). With managed state (below) or streaming running totals, only single-function primitives are allowed - sum(col), avg(col), count(col), count(*), min(col), max(col). Precompute compound expressions with derive first.
forward_fill
Fills nulls with the last non-null value per partition and order:
Code
Optional per-column default values, and a history block (from, column, order_by, partition_by) to source history from another frame. Adds __ff_{name}_original_value and __ff_{name}_forward_filled helper columns.
gap_fill
Generates the missing rows in a sequence:
Code
Sequence types: integer (step_size, start_value/end_value or min/max), date, datetime (interval step_size, end_value: now = watermark), or string (expected_values list). Adds __gf_flag (true on generated rows) and __gf_forward_filled_from columns.
SQL transforms
Instead of from + steps, a transform can be one SQL query:
Code
Tables are referenced by FQN. In a transform query the available frames are builds.* and any earlier transforms.* - sources are consumed by the build stage, so read them in a build. Plain SELECT, SELECT + JOINs, and set operations (UNION / UNION ALL / INTERSECT / EXCEPT) are supported - no CTEs. Unknown table references list the available frames in the error.
Stateful transforms
aggregate, forward_fill, and gap_fill can keep state across runs so results accumulate:
Code
Where state lives depends on the mode:
| Mode | State storage |
|---|---|
| batch | Parquet state files per step, committed after all destinations succeed |
| stream | Spark checkpointed state (with the stream checkpoints) |
In batch mode, state is written atomically after destinations succeed and discarded entirely if the run fails - a failed run leaves state exactly as it was. With window set, streaming aggregates become windowed (tumbling/session) group-bys; without it they are running totals. state.enabled: true on a non-stateful step type is a validation error.
Related pages
- Pipeline Spec Overview - the full spec model
- Sources - the frames transforms read from
- Destinations - write the results
- Checkpoints and Offsets - offsets vs state vs checkpoints