Pipelines
A pipeline turns raw source tables into the datasets that back object types: cleaned, joined, keyed with one row per object. Steps are written in SQL or Python, run on DuckDB for the small jobs most operations have and on Apache Spark for the large ones, and write Delta Lake tables in your own storage. Pipelines are incremental, so a build only processes what changed, and every build is a versioned set of table commits gated by data quality checks
In the platform today
- Pipelines run in the platform service, from
pipelines.yamlin the ontology folder - Each step runs one DuckDB SELECT or WITH query over its inputs, applies its checks,
expectationsand shorthandchecks(warn, drop or fail), and its schema contracts, and is merged into its Delta Lake output by key - A build publishes all of its outputs or none of them
- Pipelines run on a
trigger:orschedule:(intervals, daily times, cron lines in a time zone, landed tables and other pipelines' results, combined withallandany) with retries, one build at a time, automatic pause after repeated failures and skipping of up-to-date steps - Staleness, building one table with its out-of-date ancestors, dataset rollback and quarantine with replay are endpoints under
/api/v2/datasetsand/api/v2/quarantine - Runs, check results, quarantined rows, schema changes and lineage edges are in
ops.pipeline_runs,ops.quality_results,ops.quarantine,ops.schema_changesandops.lineage_edges
- The SQL header format, Python steps, choosing the engine by input size, incremental builds by partition and column-level lineage further down this page
The built format
A step names its output, key, inputs, one DuckDB SELECT and its checks under expectations, each a row predicate or a whole-output check with onFail set to warn, drop or fail. Steps run read-only with no file or network access, at validate, preview and build
pipelines:
- id: fleet
name: Fleet status
owner: Maintenance systems
editors: [maintenance-control]
trigger:
all:
- { cron: "0 6 * * 1-5", timezone: America/Halifax }
- { landed: [raw.mis_aircraft, raw.flight_log] }
retry: { attempts: 3, delay: 60s }
pauseAfter: 3
steps:
- output: gold.aircraft
key: fleetNumber
inputs: [raw.mis_aircraft, raw.flight_log]
inputContracts: { raw.mis_aircraft: additions }
contract: exactAnyOrder
sql: |
select a.fleet_number as fleetNumber, ...
from raw.mis_aircraft a left join (...) f using (fleet_number)
checks:
- { primaryKey: [fleetNumber] }
- { notNull: [registration], onFail: drop }
- { values: { status: [In service, AOG, In check, Stored] } }
expectations:
- { name: Hours not negative, row: "hours >= 0", onFail: drop }
Pipelines are also edited on the service, and the Pipelines screen in Data reads and writes through it when connected. The API lists, creates, edits and deletes pipelines and steps, validates them, previews a step on the first rows of its inputs without writing, and runs a pipeline. Edits are written into pipelines.yaml, so unchanged pipelines keep their text and comments. A write is refused when the file changed since the editor read it, and is backed up, recorded and audited. Editing needs an administrator, a group in builders.pipelines.editors or one in the pipeline's own editors
A preview runs the step's SQL in a DuckDB connection with no file or network access, with earlier steps of the same draft computed in memory, and evaluates its checks on the result. A pipeline also runs on a data branch like any other route
Builds are all or nothing
Each step's result is held until every step of the build has passed, and later steps read the held results of earlier ones. Only then is each result merged into its output. A step that fails, through its SQL, a refusal, a contract or a check with onFail: fail (BUILD_BLOCKED), leaves every output as it was, so the change feed and the sync after it see nothing. Spark and score steps read the lake directly, so the held outputs they read are merged first, and anything written before a failure is restored to its version from before the build. The failed run is in ops.pipeline_runs with failed_step, the output of the step that failed, and each output's status (built, skipped, failed or not published) with its versions before and after in outputs
Triggers and schedules
With the pipeline scheduler switched on, a service setting, the service checks every 30 seconds and builds each due pipeline, in dependency order, then syncs the object types its outputs back. A schedule: line takes every 15 min, every 1 h, every 1 d, hourly, daily 06:00, cron 0 6 * * 1-5 America/Halifax or on change; anything else is a label. trigger: takes precedence and takes the same conditions as a tree
| Condition | True when, since the pipeline's last scheduled run |
|---|---|
{ every: 15m }, { daily: "06:00" } | A slot has started, counted from local midnight in the ontology's time zone |
{ cron: "0 6 * * 1-5", timezone: America/Halifax } | A cron slot has started. Five fields with L (the last day of the month), MON#2 (the second Monday) and 5L (the last Friday); the zone defaults to the ontology's |
{ onChange: true } | An input the pipeline does not make itself has a new version |
{ landed: [raw.a, raw.b] } | Every one of these tables has a new version |
{ succeeded: p }, { failed: p }, { finished: p } | Pipeline p had a build with that result |
{ logicChanged: true } | This pipeline's steps changed |
{ all: [...] }, { any: [...] } | Every one, or any one, of the conditions inside |
A time the clocks skip when daylight saving starts never fires that day, and a repeated time fires once, at its first occurrence. Slots missed while the service was down fire once. The first look at a new or edited trigger only notes where everything stands
Running unattended
- Retries:
retry: { attempts: 3, delay: 60s }(1 to 10 attempts, a delay up to 10 minutes) restores and retries a build that failed on storage, network or a lost commit. Refusals, SQL errors, contract violations and failed checks are never retried. The run keeps its attempts and the earlier errors - One build at a time: a second build of the same pipeline waits up to 5 seconds by default and then gets 409
RUN_IN_PROGRESS, on any copy of the service. A schedule that finds the pipeline building waits for a later pass - Pause after failures:
pauseAfter: 3pauses the schedule after that many failed scheduled builds in a row (0 never). It resumes when a build succeeds, or withPOST /api/v2/pipeline-schedules/{id}:resume;:pausepauses it by hand with a reason. Pausing, resuming and edited triggers are audited - Skip what is up to date: a step whose logic and input versions are unchanged since its last build, and none of whose inputs was rebuilt in the same build, is skipped and recorded as skipped with the reason. Score steps and SQL that reads the clock or a random value always run;
{"force": true}onPOST /api/v2/pipelines/{id}/runsruns everything - Downstream of a failure: a scheduled pipeline that reads from one that failed or was skipped in the same pass is skipped, with the reason in its schedule state and the audit log
In the app, the Pipelines screen in Data shows this for each pipeline. Schedule has its trigger and each condition, the next slot, retries, when it pauses after failures, and Pause or Resume. Builds lists each build with the steps built and skipped, its attempts and each output's result. Outputs says whether each output is up to date and why not, lists its versions, builds one table and rolls it back after a confirmation in place. Quality has the quarantined rows to fix and replay or discard, the schema contracts with their violations and Accept new schema, and the schema changes seen
Out of date, build one table, roll back
| Endpoint | Does |
|---|---|
GET /api/v2/datasets/staleness | Every pipeline output as up to date or out of date, with the cause: data (the inputs that moved, with the version built from and the version now), logic, upstream, new or always |
POST /api/v2/datasets/{name}:build | Builds the table and the out-of-date ancestors it reads from, across pipelines, each pipeline as one all-or-nothing build, then syncs the object types they back. {"preview": true} returns the plan, {"force": true} builds every ancestor. Needs the editors of every pipeline that would run |
GET /api/v2/datasets/{name}/versions | The table's versions, the build that made each and whether it can be restored |
POST /api/v2/datasets/{name}:rollback | { "version": 12 } or { "runId": "build_…", "before": true }, with an optional reason. Restores the table and the other outputs built with it ("together": false for this table only) as a new Delta commit, then re-syncs the object types they back. Refused with 409 HISTORY_VACUUMED when the history is gone |
GET /api/v2/pipeline-schedules | Each pipeline's trigger, how it is read, what it still waits for, its last scheduled run and whether it is paused |
Pipeline outputs can be rolled back by administrators and by the pipeline's owner group, the groups in its editors or the group or person in owner; raw tables by administrators only; ops, object and edit tables never. A rolled-back output stays as it is until its inputs or logic change, because the next build skips it as up to date. Builds, rollbacks and schedule changes are audited as pipeline.run, dataset.build, dataset.rolledBack and pipeline.schedule.*. Shorthand checks, quarantine and schema contracts are described on data quality checks, and failing pipelines can raise alerts through monitors
From raw data to object data
Data moves through three layers, each a schema in your catalogue. Raw holds what connectors wrote, unchanged, with one row per source change. Clean holds typed, deduplicated, current-state tables, one per source entity, with consistent names and units. Ontology holds the backing datasets of object types and link types: one row per object, keyed on the object's primary key, with exactly the columns its properties map to. Pipelines are the steps between the layers
The layers are a convention, not a constraint, but they pay for themselves. Raw lets you rebuild anything. Clean is where source quirks are handled once: the point of sale that reports tubs as "units", the ERP that stores times in local time without a zone. Ontology tables are shaped for the object store, so the sync service can read their change feeds directly
Writing a step
In the platform service a step is written in pipelines.yaml: its output, key, inputs, one DuckDB SELECT and its checks under expectations, each a row predicate or a whole-output check with onFail set to warn, drop or fail
pipelines:
- id: fleet
name: Fleet, flying and installed equipment
owner: Maintenance control systems
schedule: every 15 min
steps:
- output: gold.stations
key: code
inputs: [raw.ops_stations, raw.hr_shifts, raw.mis_work_orders, raw.sys_clock]
sql: |
select st.station_code as code, st.station_name as name, st.city, st.province, ...
from raw.ops_stations st ...
expectations:
- { name: One row per station, check: "count(*) = count(distinct code)",
onFail: fail }
- { name: Known station type, row: "stationType in ('Base', 'Line')", onFail: fail }
On request, a step can be a SQL file with a header that reads only the input rows new since the last build, or a Python function over data frames, for when a step needs a library such as a forecast or a fuzzy match
Engines: DuckDB and Apache Spark
Most operations data is smaller than people expect. Two years of point of sale for fourteen shops, every production order and every lab result for a creamery fit comfortably on one machine. For data that size a distributed engine adds start-up time and cost without making anything faster. Pipelines therefore run on DuckDB by default, reading and writing Delta Lake tables through the open-source Delta Lake Rust library, and move to Apache Spark only when the input is large enough to need it
On request, engine: auto picks DuckDB or Spark by input size, and SQL steps are written once and run on either engine, so a step can move to Spark as its data grows without any change to its downstream readers
Pipelines run on DuckDB by default. A step opts in to Apache Spark with engine: spark, and fallback: duckdb runs it on DuckDB when Spark or Java 21 is missing. The step runs in a local Spark session with Delta Lake, started on first use and reused, reading its inputs under their lake names, so the SQL is unchanged apart from dialect. Checks behave as on DuckDB, and the output is written with a Delta merge by key, so its change data feed shows only real changes. Choosing the engine by input size with engine: auto and Spark clusters on Kubernetes are delivered on request. A step with kind: score scores rows with a trained model
Pipelines on edge hosts
Because DuckDB needs no cluster, the same steps can run on an edge host next to the edge agent. A plant that must keep working through a lost link can build its own clean and ontology-layer tables locally from the raw data the agent buffers, and the Ontology on site keeps serving fresh objects. When the link returns, the local table versions are reconciled with the cloud ones: steps rerun in the cloud from the same inputs, and any row whose result differs is listed for review rather than silently overwritten
Incremental builds
A build processes only what changed upstream since the last successful build. Each step records, per input, the Delta table version it last consumed. On the next build it reads the change data feed between that version and the current one, applies its logic to those rows, and updates its output according to its mode
| Mode | How the output is updated | Use for |
|---|---|---|
append | New rows are added | Events, readings, logs |
merge | Rows are upserted by key; deletes in the input delete rows | Current-state tables and object backing datasets |
partition | Affected partitions are recomputed and replaced | Daily rollups, aggregates by date |
snapshot | The whole output is recomputed | Small tables, or logic that depends on every row |
When a step's code changes, its output is rebuilt from scratch on the next build, because the old rows were produced by the old logic. Downstream steps then see a full change set and rebuild incrementally from it. A typical incremental build of the creamery's whole graph, about forty steps, runs in under a minute; a full rebuild takes around twelve
Late and corrected data
Sources correct themselves. A lab result is amended a day later, a point of sale replays a batch of sales after an outage, the ERP back-dates a production order. Incremental builds handle these without special code, because a correction is just another change in the input's change data feed: a merge step upserts the corrected row and a partition step recomputes the partition the corrected row falls in, even if that partition is weeks old. What you do need to decide is how late is too late. Each partitioned step has a lateness window, 30 days by default; corrections older than that are written to the quarantine table and flagged, so that a closed month is not silently reopened
An incremental build and a full rebuild of the same inputs produce the same output. Every publish of a pipeline checks this on a sample: it runs both on a branch and compares row hashes. A step whose logic depends on row order or wall-clock time fails the check and has to be marked snapshot
Change capture headers
A merge step over a source's changes takes three more headers, described in full on change capture. They decide which of two rows for one key is newer, what counts as a delete, and whether old states are kept
| Header | Does | Example |
|---|---|---|
@sequence | The column, or list of columns, that orders rows for one key. A row is applied only if its sequence is greater than the one stored for that key. Left out, it defaults to _ms_source_position, or _ms_source_ts then _ms_source_position for watermark sources. See sequencing and ordering | @sequence pos_revision, _ms_source_position |
@deleteWhen | A condition that turns a voided, cancelled or closed row into a delete in the output, while the raw dataset keeps the row as it was. See deletes and tombstones | @deleteWhen is_void = 1 |
@history | Writes a history dataset with every state of every key beside the current-state output, in the same Delta commit. See current state and full history | @history creamery.clean.plan_lines_history |
Checks
Checks are assertions about a step's output, checked on every build before the output is committed. Each has a name, a condition, and what to do when rows violate it. They are how bad data is stopped at the pipeline instead of discovered on a planner's screen
warn: commit anyway and record the violation count on the dataset's healthdrop: leave violating rows out of the output and record them. In the platform service today,onFail: dropkeeps each dropped row inops.quarantinefor someone to fix and replayfail: commit nothing from this step, mark the build failed and stop everything downstream of it
Checks can also be set on a whole table rather than on rows: a minimum row count, a maximum change from the previous build, freshness of the newest row, uniqueness of the key. A failed table check on an ontology-layer dataset means the object type keeps serving its last good version, and the objects show a data health banner. Checks are covered in depth in data quality checks
Builds, schedules and branches
A build is a run of part or all of a pipeline graph. It has an id, the code version of each step, the input versions each consumed and the output versions each produced. All outputs of a build commit together, in dependency order, only after every check in the build has passed. If anything fails, nothing from the build is visible, and the graph keeps serving the outputs of the last successful build
- Triggers: on upstream change, on a cron schedule, when named tables have landed, after another pipeline's build, or on demand, combined with
allandanyas described above. Making upstream change the default for steps reading change capture sources is delivered on request - Coalescing: changes that arrive while a build is running are picked up by the next build. One build of a pipeline runs at a time; a scheduled build waits for a later pass, and starting the next build as soon as the current one ends is delivered on request
- Freshness targets: learned per dataset by dataset health and alerted on by monitors. A fixed target per output, for example "ontology.scoop_shops no older than 2 minutes", is delivered on request
- Rollback: restoring an output, and the outputs built with it, to the version from an earlier build is a Delta Lake restore, recorded as a new commit, followed by a sync of the object types they back (above). Rebuilding everything downstream afterwards is delivered on request
Pipelines build on data branches. A build requested with the X-MSO-Branch header, or ?branch=, runs the pipelines as they are on main against the branch's data, and its outputs land in the branch's own copy of each table, made on the table's first write. The branch's diff compares those outputs with main by the step key, and a merge applies them table by table, or the branch is discarded. Pipeline definitions are edited on main, and changing a step's code on a branch is delivered on request
Lineage and the catalogue
Every dataset a pipeline writes is registered in Unity Catalog (open source) as a table in the three-level namespace catalog.schema.table, with its schema, owner, grants and access labels. The pipeline compiler records column-level lineage for every step, from the SQL it parses or from the expressions in the Python frame plan, and writes it to the catalogue. That lineage continues through the Ontology to properties, functions and actions, so lineage can show a planner's "hours of cover" back to the point of sale column it came from
Access labels propagate along the same lineage. A column derived from a table labelled FINANCE carries FINANCE unless a step explicitly removes it, which requires the declassify permission on that access label and is written to the audit log. Joins carry the union of their inputs' access labels
Limitations
- A build commits all or nothing: one failed check hides every output of the build, including outputs that passed, until the next successful build
- Changing a step's code rebuilds its output from scratch, and everything downstream sees a full change set
- SQL that uses a function available on only one engine must pin that engine, and Spark-only steps cannot run on edge hosts
- Steps that depend on row order or wall-clock time fail the incremental check and have to run as
snapshot - Corrections older than a partitioned step's lateness window are quarantined, not applied, so a closed period is never reopened without a person replaying them
- Results built locally on an edge host during a lost link are reconciled, not merged automatically; rows that differ wait for review
- Pipeline branches rely on branches and proposals, so branch builds depend on that part of the platform