Steps & ETL
A step is a task dagron already knows how to run. The task names it with
step: and configures it with with:; dagron supplies the command
and the image, and checks with: by the step's own rules before the run is made.
Five steps cover an extract and its cleaning: data from Postgres, a JSON API, a file drop or
an Airbyte connector, landed as files, then cleaned with a YAML recipe. There is no script to
write and no image to build per pipeline.
On this page
- What a step task is
- csv-clean: clean with a recipe
- sql-export: a query's rows to a file
- http-extract: a JSON API's records
- file-fetch: a partner's file drop
- connector: a SaaS source through Airbyte
- Extract, then clean
- Rebuilding models: State plans
- Moving an existing pipeline
- What 0.12.0 does not do
- Where the rest is
What a step task is
A step task is a leaf task with step: in place of a command. When a workflow is
expanded, dagron checks its with: and turns it into an ordinary task: the step's
binary as its command, the step's image unless the task names one, and with:
passed as JSON in DAGRON_STEP_WITH. The executors see nothing new.
| Step | Binary and image | What it does |
|---|---|---|
csv-clean | dagron-step-csv, mancube/dagron-step-csv | Cleans a CSV, JSON lines or Parquet file with a YAML recipe. |
sql-export | dagron-step-sql, mancube/dagron-step-sql | Exports a query's rows from Postgres to CSV, JSON lines or Parquet. |
http-extract | dagron-step-http, mancube/dagron-step-http | Pages through a JSON API and lands its records as JSON lines. |
file-fetch | dagron-step-fetch, mancube/dagron-step-fetch | Copies a file drop (SFTP, FTPS, HTTPS) into the landing location, each file whole. |
connector | dagron-step-connector, installed into the connector's own image | Runs an existing Airbyte source and lands each stream as JSON lines. |
- Checked before it runs. A misspelt key, step, function or condition is refused
where the workflow is saved (a
400from dagron-api), synced from Git, and run, naming the task and the step, rather than when the task starts. A credential written where only its variable's name belongs (a password in a DSN, a token in an HTTP spec) is refused there too, before it is stored. A value still holding a{{ … }}placeholder is checked once the placeholder is filled. - Credentials are secrets.
with:is stored with the workflow and shown wherever it is, so a credential never goes in it. The task gets the credential inenv:from a dagron secret (value_from: { secret: … }), andwith:names the variable. - Whole or not at all. Each step writes its output beside the target and moves it
into place once it is complete: a local file renamed, an object a multipart upload
completed. A failure or a stop leaves nothing at the output. The locations are paths, or
s3://,gs://,az://andfile://URLs, with each cloud's credentials read from the environment as its own tools read them. - The image. A step uses the release's
mancube/dagron-step-*image unless the task names one, or the operator setsDAGRON_STEP_CSV_IMAGE,DAGRON_STEP_SQL_IMAGE,DAGRON_STEP_HTTP_IMAGEorDAGRON_STEP_FETCH_IMAGEon dagron-api and the engine (a mirror, or a pinned digest). The connector step runs in the connector's image instead (below). - Versioned.
step: csv-clean@1pins whatwith:means.GET /api/stepslists each step with its versions and keys, andPOST /api/steps/checkchecks awith:without saving anything, which dagron-mcp offers an agent asdagron_list_stepsanddagron_check_step. - One line on stdout at the end, which a
when:downstream can read: rows or records in and out, and where they went.
csv-clean: clean with a recipe
One image cleans every pipeline's data. The cleaning is a YAML recipe in the workflow, so changing it is a change to the workflow file, and nothing is built per pipeline.
- name: clean_orders step: csv-clean with: input: s3://lake/raw/shop/orders/ds={{ ds }}/orders.parquet output: s3://lake/clean/shop/orders/ds={{ ds }}/orders.parquet rejects: s3://lake/rejects/shop/orders/ds={{ ds }}/orders.csv recipe: steps: - transform: { customer_email: [trim, lower] } - filter: { status: "!= test" } - cast: { id: int, amount: decimal(2), updated_at: timestamp } - dedupe: [id]
The recipe's steps run in order, each a mapping with one key:
| Step | Does |
|---|---|
rename, select, drop | Name, keep or remove columns; select and drop take wildcards. |
transform | trim, lower, upper, on a column or a wildcard. |
replace | Whole values, a substring, or a regular expression with $1 groups. A pattern runs in time linear in the cell, so a recipe cannot hang the step. |
filter | Keeps a row only if every condition holds: not_null, a wildcard, a comparison (">= 0"), { in: [...] }. |
cast | int, decimal(N), float, date, timestamp; narrower than a language's parser on purpose. |
derive, split | Add columns from a template ("{first} {last}") or by splitting a value. |
dedupe | Keeps the first row of each key. |
A row a filter, a cast or a dedupe drops goes to rejects where it is set, as
it was read, with the recipe step that dropped it and why (cast: amount is not
decimal(2)). on_invalid: fail fails the task on the first value that does
not cast instead (exit 3).
Formats. The same recipe reads and writes CSV (with a delimiter, no header, or an
encoding such as windows-1252), JSON lines (nested objects flattened to
customer.email) and Parquet. .gz or .zst after the
suffix compresses as it streams. The recipe's casts are the output's schema: an
int column is a Parquet INT64, a decimal(2) a DECIMAL(18, 2). A
* in the input's last part reads every file it matches as one input. Options go
with the location: input: { url: "s3://raw/*.csv.gz", delimiter: ";" }.
Writing a recipe. dagron-step-csv init --sample FILE drafts one from a
sample; preview shows what each step keeps and drops; test holds
a pipeline to its expected output, rejects and schema; --check compiles a
recipe against a file's header without reading a row, for CI. dagron-step-csv
schema prints the recipe language as a JSON Schema for an editor's completion, which
dagron-api also serves. In the console, the Blocks palette's Clean CSV block adds the
task and checks the recipe as saving would.
It does not evaluate code or run a command. That is what makes a recipe safe to accept from people who may not run arbitrary code. Logic a recipe cannot express belongs in a task of its own, beside this one.
sql-export: a query's rows to a file
- name: extract_orders step: sql-export env: - { name: SQL_PASSWORD, value_from: { secret: SHOP_DB_PASSWORD } } with: engine: postgres dsn: postgres://etl@shop-db:5432/shop # the user, never the password query: >- SELECT id, customer_email, amount, status, updated_at FROM orders WHERE updated_at >= date '{{ ds }}' AND updated_at < date '{{ ds }}' + 1 output: s3://lake/raw/shop/orders/ds={{ ds }}/orders.parquet
with: takes four keys: engine, dsn,
query and output. The password comes from SQL_PASSWORD,
given from a secret, and a DSN that carries one is refused. The output is CSV, JSON lines or
Parquet by its suffix, typed Parquet straight from Postgres's COPY, with the clean
step's output options. null_as keeps a NULL apart from an empty string in every
format, which an export's rows need. The task's timeout_secs bounds the export.
Postgres only, as a step. Other stores unload with their own statement (ClickHouse's
INSERT INTO FUNCTION s3(…), Snowflake's COPY INTO, BigQuery's
EXPORT DATA), run by dagron-step-sql as an ordinary task in its
exec mode. That binary also runs one statement with a row and byte budget
(SQL_MODE exec, scalar, rows,
script) against ClickHouse, StarRocks, Doris, MySQL, Postgres, Redshift,
Snowflake, BigQuery, Databricks or DuckDB, and checks that a partition holds the same rows on
two stores (dagron-step-sql parity); its README has both.
http-extract: a JSON API's records
- name: extract_reviews step: http-extract env: - { name: REVIEWS_API_TOKEN, value_from: { secret: REVIEWS_API_TOKEN } } with: url: https://api.example.com/v1/reviews params: { day: "{{ ds }}" } auth: { bearer: REVIEWS_API_TOKEN } # the variable's name, not the token records: data # where the list is in each response paginate: { cursor: { from: next_cursor, param: cursor } } max_pages: 500 output: s3://lake/raw/shop/reviews/ds={{ ds }}/reviews.ndjson
Paging is one of page (a page number until a page has no records),
offset, cursor (from the body, sent back as a parameter),
next_url and link (the Link header's
rel="next"). Omitted, it is one request. max_pages (1000 by default)
and max_page_bytes (64 MiB) bound a run, which fails past them rather than page
forever.
Auth is { bearer: VAR } or { header: X-Api-Key, value_from: VAR
}, from a variable the task is given from a secret. A credential in the URL, in a header,
or in anything that looks like a key is refused, and one is masked in every error message. It
goes over plain http:// only to this machine, unless
allow_plain_http says the network is trusted.
Each record lands one to a line as the API sent it: key order and numbers as written. A 429,
a 5xx or a failed connection is retried (retries, 5 by default, with a backoff that
honours Retry-After). A 4xx, retries run out, or records missing where
records: says fail the run and land nothing.
file-fetch: a partner's file drop
- name: fetch_partner step: file-fetch env: - { name: PARTNER_SFTP_KEY, value_from: { secret: PARTNER_SFTP_KEY } } with: source: sftp://dagron@sftp.partner.example/outbox/orders_{{ ds }}.csv auth: { private_key: PARTNER_SFTP_KEY } # or { password: VAR } host_key: ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAA… # the server's, pinned output: s3://lake/raw/partner/orders/ds={{ ds }}/orders.csv
Sources: sftp://, ftps:// (FTP over TLS, explicit
AUTH TLS) and https://. Plain ftp:// is refused, as it
sends the password in the clear. SFTP trusts the one host key host_key pins,
never a key on first sight. FTPS and HTTPS are verified against the system's roots, or against
ca_cert alone where it pins a partner's own CA or a self-signed certificate.
Several files: a * or ? in an SFTP or FTPS path's last part
fetches every file it matches, up to max_files, into an output
ending in /, each under its own name. The files land byte for byte, each whole,
and none lands until all are fetched. max_bytes (10 GiB unless set) caps them
together.
connector: a SaaS source through Airbyte
Writing connectors one by one is a maintenance sink, so this step runs one that exists: an
Airbyte source, in its own image, as Airbyte publishes it. dagron installs the adapter,
dagron-step-connector, into the task at /dagron/bin from the
operator's DAGRON_CI_EXEC_IMAGE. The step therefore runs on the Docker or
Kubernetes executor with that setting.
- name: extract_payments step: connector docker_image: airbyte/source-stripe:7.1.0 # the connector, as published env: - { name: PAYMENTS_API_KEY, value_from: { secret: PAYMENTS_API_KEY } } with: config: # the connector's own config account_id: acct_1234 client_secret: { from_env: PAYMENTS_API_KEY } start_date: "2024-01-01T00:00:00Z" streams: [charges, customers] output: s3://lake/raw/payments/ds={{ ds }}/ # charges.ndjson, customers.ndjson state: s3://lake/state/payments.json # only the new rows, run to run
- A run asks the connector for its spec, then
checks the config: a credential it refuses fails the run with the connector's own reason, masked. Thendiscoverandread. Each stream lands as<stream>.ndjson, the records' data as the connector wrote it, and none until the read has ended well. - Only the new rows. With
state, a file outsideoutput, the connector's state is read before each run and written back after it. A stream that offers incremental reads is read from where the last run ended; withoutstate, each run reads everything from the config's start date. - Credentials. A credential in
configis written{ from_env: VAR }. A literal value under a key that names one is refused when the workflow is saved, and one in any field the connector's own spec marks secret is refused before the connector is asked anything. Credentials are masked in its logs, short ones as whole tokens. - Stray prints. A line the connector prints on stdout that is no Airbyte message may
hold a record's data, so it is counted, not logged.
log_stray: truepasses each on, masked, for debugging a connector.
Which images run, on which architectures, and the connectors' licences are on the
connectors' compatibility page, docs/CONNECTORS.md.
examples/etl/declarative/extract/saas_faker.yaml extracts and cleans Airbyte's
faker source, which needs no account.
Extract, then clean
examples/etl/declarative/extract/shop_daily.yaml is one day of a shop in four
step tasks, with no script and no image of its own. The examples on this page are taken from
it.
extract_orders step: sql-export Postgres → raw/shop/orders/ds=…/orders.parquet extract_reviews step: http-extract a paged JSON API → raw/shop/reviews/ds=…/reviews.ndjson clean_orders step: csv-clean → clean/shop/orders/ds=…/orders.parquet clean_reviews step: csv-clean → clean/shop/reviews/ds=…/reviews.parquet
Each extract takes one day ({{ ds }}), and each clean keeps a rejects file
saying why every dropped row went. A re-run of a day writes the same objects, byte for byte,
so retrying a failed day or backfilling another is safe; the compose stack's test holds it to
that. partner_drop.yaml fetches a partner's SFTP file and cleans it;
partner_batch.yaml fetches every file of a day from FTPS with a wildcard and
cleans them as one input.
$ PG_URL=postgres://etl:etl@127.0.0.1:5432/shop examples/etl/declarative/extract/e2e.sh $ examples/etl/declarative/extract/compose-e2e.sh # or the compose stack, with MinIO as the lake
Rebuilding models after a SQL change: State plans
A state plan is the other way SQL runs: given a change to a project's SQL, rebuild the models
it touches and nothing else. The plan comes from the planner, dagron-state envelope
joins it with the target's manifest (each model's command, env and secrets, and which plans need
no reviewer), and the rebuild is one ordinary run, each model a task running the manifest's
command (dagron-step-sql in the example). A plan bigger than the manifest's auto_approve waits for a person, in the
console under State plans.
- Pending, Applied, Scratchpad: plans waiting on a gate; every rebuild a plan made,
and who let it through (a person, or the target's
auto_approve); and a place to paste a plan and explain it, which runs nothing. - Where it came from: the target, the commit and repository, and the gate it waits on.
- The bytes: the envelope the gate binds, by its sha256. Approving sends that hash back, and the apply job submits those bytes or nothing.
- What rebuilds: how many of the project's models, each with why (changed, or downstream of one, through which column) and what it waits on. Below it: each model's SQL, the command and env from the manifest, and Approve or Reject.
examples/state
is the pipeline: plan, the review when one is needed, apply, then commit the new state. It runs
offline as far as the explanation. STATE_PLAN_USECASES.md
says where a plan comes from and why each piece is as it is.
Moving an existing pipeline
Four worked examples move a SaaS extract to dagron from a tool teams already run. Each keeps
the source, the streams and the lake layout it had, and swaps the platform around them for two
steps: connector (the same Airbyte connector image) and csv-clean
(the normalization, dbt model or pandas function, as a recipe).
| Moves from | Source | Shows |
|---|---|---|
| An Airbyte connection (OSS or Cloud) | airbyte/source-stripe | The connection's settings, field by field; two cleans. |
| An Airflow DAG: an Airbyte sync, then PythonOperators | HubSpot | default_args, >>, schedules and backfills; an auth choice in the config. |
| A Meltano project (a Singer tap and target) | GitHub | Moving from a tap to the Airbyte source for the same API. |
| A managed Fivetran connection | Salesforce | Your own OAuth app in place of the vendor's; loading a warehouse from the lake. |
Each needs a real account and the secrets its header names. They are in
examples/etl/declarative/migrate,
with the concepts of the five tools side by side.
What 0.12.0 does not do
- Extraction as a step is Postgres, JSON APIs, file drops and Airbyte connectors.
Other databases unload with their own statement, through
dagron-step-sql'sexec. Singer taps and implicit FTPS (port 990) are not built. - No expressions in a recipe, by design (above).
- Not deferred. A step holds its worker while it runs.
- The connector step needs the Docker or Kubernetes executor with
DAGRON_CI_EXEC_IMAGEset, which is what installs its adapter. - The run page does not draw a clean's statistics yet. The API serves them.
Where the rest is
- dagron-step-csv — every recipe step, condition, cast, format option and exit code.
- dagron-step-sql — the stores, every
SQL_MODE, export andparity. - dagron-step-http — the spec, each paging form, what a run does.
- dagron-step-fetch — SFTP, FTPS and certificates, several files.
- dagron-step-connector — the spec, credentials, state, what a run does.
- CONNECTORS.md — which connector images run, their licences, choosing how to read a source.
- examples/etl/declarative — the reference setup on a laptop, a pipeline of your own, CI for a pipelines repository, and moving to object storage and a cluster.
- API.md —
GET /api/stepsandPOST /api/steps/check.