The problem
An ETL job is mostly three kinds of step: clean the rows, check them, add them up. None of them is hard. But the cleaning rule lives in a scheduler task, the same check is written again as a SQL model, and the notebook that reports the totals keeps its own copy. Change the rule and you change it three times — if you remember all three.
OpenFlange makes each step a pipe. A pipe is a data-processing step with declared inputs and outputs. One short file connects the pipes and one command runs them. The same files run on your laptop, from cron, in CI, or inside any tool that speaks the standard.
What you build here: a CSV of orders goes in; customer names are cleaned, bad rows are set aside together with the reason, paid orders are totalled per customer; a CSV comes out. Seven of the eight steps are standard pipes that ship with the runner. The eighth is fifteen lines of Starlark that you write.
What ran, and where
Every command in steps 1 to 4 was run with openflange 0.0.1 (go1.27.1 linux/amd64) and its output is pasted as it came out; only the durations change from run to run. Steps 5 to 7 say plainly what was not run.
1. The files
You need the openflange command, release v0.0.1, which needs Go (details in the quickstart):
go install github.com/openflange/openflange-go/cmd/openflange@v0.0.1The example is examples/etl-csv in the openflange-go repository: clone it and run the commands from that directory, or create the files from this page. Lay out an empty directory like this:
orders-etl/
├── orders.csv
├── OPENFLANGE.md
├── pipeline.yaml
├── openflange.yaml
├── pipes/
│ └── total-per-group/
│ ├── OPENFLANGE.md
│ ├── total.star
│ └── tests/
│ └── total-per-group.test.yaml
└── tests/
└── orders-etl.test.yamlThe input has the usual problems: a name with spaces and capitals, an amount that is not a whole number, a missing customer, a date in another format, and a refunded order that must not be counted.
order_id,customer,day,amount_cents,status
1001, Ada ,2026-11-30,1000,paid
1002,bob,2026-11-30,550,paid
1003,ADA,2026-12-01,3200,paid
1004,bob,2026-12-01,12.5,paid
1005,cy,2026-12-01,900,refunded
1006,,2026-12-02,700,paid
1007,bob,2026-12-02,2000,paid
1008,cy,02/12/2026,1500,paid
1009,cy,2026-12-02,450,paidThe pipeline. Each node names a pipe and says which output it reads from. Nothing else connects them.
spec: openflange.org/pipeline/v0.1
nodes:
decode:
pipe: std:csv-decode
inputs:
in: {from: inputs.csv}
clean:
pipe: std:map
inputs:
in: {from: decode.outputs.out}
parameters:
expr: 'dict(item, customer=item["customer"].strip().lower())'
check:
pipe: std:validate-schema
inputs:
in: {from: clean.outputs.out}
parameters:
schema:
type: object
required: [order_id, customer, day, amount_cents, status]
properties:
customer: {type: string, minLength: 1}
day: {type: string, pattern: "^[0-9]{4}-[0-9]{2}-[0-9]{2}$"}
amount_cents: {type: string, pattern: "^[0-9]+$"}
status: {enum: [paid, refunded]}
typed:
pipe: std:cast
inputs:
in: {from: check.outputs.valid}
parameters:
fields: {order_id: integer, amount_cents: integer}
paid:
pipe: std:filter
inputs:
in: {from: typed.outputs.out}
parameters:
expr: 'item["status"] == "paid"'
group:
pipe: std:window
inputs:
in: {from: paid.outputs.out}
parameters:
size: 1000000
partitionBy: 'item["customer"]'
total:
pipe: ./pipes/total-per-group
inputs:
groups: {from: group.outputs.out}
encode:
pipe: std:csv-encode
inputs:
in: {from: total.outputs.totals}
outputs:
totals: {from: encode.outputs.out}
rejected: {from: check.outputs.rejected}| Node | Pipe | What it does |
|---|---|---|
decode | std:csv-decode | Reads CSV text into records. Every value stays a string: nothing is guessed. |
clean | std:map | Trims the customer name and puts it in lower case. |
check | std:validate-schema | Checks each row against a schema. A row that fails goes to rejected with the reason. |
typed | std:cast | Turns order_id and amount_cents into integers, exactly. |
paid | std:filter | Keeps the paid orders. |
group | std:window | Groups the orders by customer: one frame per customer when the input ends. |
total | ./pipes/total-per-group yours | Your step: the number of orders and the sum of cents in each frame. |
encode | std:csv-encode | Writes the records as CSV text. |
The job gets a contract of its own, so it can be tested, locked and reused as one pipe. kind: text says that csv and totals carry CSV text rather than records.
---
spec: openflange.org/pipe/v0.1
id: orders-etl
version: 0.1.0
title: Orders ETL
description: Reads an orders CSV, cleans and validates every row, and writes the number of paid orders and the paid total per customer as CSV; rows that fail validation are routed to `rejected`.
license: Apache-2.0
keywords: [etl, csv, validate, aggregate, example]
maturity: experimental
scope: dataset
requires: [windows]
inputs:
csv:
kind: text
mediaTypes: [text/csv]
description: 'Orders with a header row: order_id,customer,day,amount_cents,status.'
outputs:
totals:
kind: text
mediaTypes: [text/csv]
description: 'CSV with a header row: customer,orders,total_cents — one row per customer, in order of first appearance.'
rejected:
required: false
description: 'Rows that fail validation, as {"item", "errors"}. If not connected, the first invalid row fails the run.'
implementation:
type: pipeline
path: pipeline.yaml
---
# Orders ETL
Implements the [OpenFlange](https://openflange.org/) specification.
CSV in, CSV out: decode, clean, validate, cast, keep paid orders, total per
customer. See [README.md](README.md) for the commands and their output.
```
csv ─▶ decode ─▶ clean ─▶ check ─┬─▶ typed ─▶ paid ─▶ group ─▶ total ─▶ encode ─▶ totals
└─▶ rejected (optional)
```
- **The whole input is held in memory by `group`.** `std:window` with
`partitionBy` and a size of 1,000,000 keeps every paid order until the end
of the input, then emits one frame per customer. A customer with more than
1,000,000 paid orders would be split into several rows. For large inputs
replace `group` + `total` with a database pipe (see the README).
- Money is integer cents; sums are exact.
- Permissions: none. Every node runs in-process.The one step that is yours, with its contract. std:window hands it one frame per customer and it returns one record per frame. Money is kept in whole cents, so the sum is exact.
# SPDX-License-Identifier: Apache-2.0
# total-per-group: one record per window frame. Money is integer cents.
def process(frame, params):
total = 0
for order in frame["items"]:
cents = order["amount_cents"]
if type(cents) != "int":
fail("amount_cents must be an integer, got %r" % cents)
total += cents
return {
"customer": frame["window"]["partition"],
"orders": len(frame["items"]),
"total_cents": total,
}---
spec: openflange.org/pipe/v0.1
id: total-per-group
version: 0.1.0
title: Total per group
description: Turns each window frame of orders into one record with the group key, the number of orders and the sum of `amount_cents`.
license: Apache-2.0
keywords: [aggregate, sum, window, starlark, example]
maturity: experimental
scope: window
requires: [windows]
cardinality: one-to-one
deterministic: true
inputs:
groups:
kind: windows
description: 'Window frames whose items are orders with an integer `amount_cents`; the partition value is the group key.'
outputs:
totals:
kind: records
description: 'One record per frame: {"customer", "orders", "total_cents"}.'
implementation:
type: script
language: starlark
path: total.star
---
# Total per group
Implements the [OpenFlange](https://openflange.org/) specification.
A Starlark script pipe, run in-process with no permissions. Put it after
`std:window` with `partitionBy`: every frame becomes one record. Amounts are
integer cents, so the sum is exact. An item whose `amount_cents` is not an
integer fails the run with `E_RUNTIME`.A short index marks this directory as the project root. That is where the lockfile will be written.
# Package index of the orders ETL example.
spec: openflange.org/package/v0.1
default: .
pipes:
- .
- pipes/total-per-group2. Run it
Check the whole graph before anything runs:
openflange validate .valid: . (8 nodes, 10 edges)Now run it. The input is bound to a file and each output to a file of its own:
openflange run . --input csv=orders.csv --output totals=totals.csv --output rejected=rejected.ndjsoncompleted in 625µs — totals: 1 chunk, rejected: 3 recordsThe totals, in totals.csv:
customer,orders,total_cents
ada,2,4200
bob,2,2550
cy,1,450And in rejected.ndjson, the three rows that did not pass, each with the reason. Nothing was dropped silently.
{"item":{"order_id":"1004","customer":"bob","day":"2026-12-01","amount_cents":"12.5","status":"paid"},"errors":[{"path":"/amount_cents","message":"'12.5' does not match pattern '^[0-9]+$'"}]}
{"item":{"order_id":"1006","customer":"","day":"2026-12-02","amount_cents":"700","status":"paid"},"errors":[{"path":"/customer","message":"minLength: got 0, want 1"}]}
{"item":{"order_id":"1008","customer":"cy","day":"02/12/2026","amount_cents":"1500","status":"paid"},"errors":[{"path":"/day","message":"'02/12/2026' does not match pattern '^[0-9]{4}-[0-9]{2}-[0-9]{2}$'"}]}Leave rejected unconnected and the first bad row stops the run with exit status 1. A bad row is either data you receive or an error you see:
openflange run . --input csv=orders.csvE_RUNTIME: item 4 does not match the schema: /amount_cents: '12.5' does not match pattern '^[0-9]+$' (node check)
hint: connect the output `rejected` to receive invalid items as data instead of failing
failed in 4ms — totals: 0 chunks3. Lock it
Record exactly what the pipeline resolved to: every standard pipe and your own step, each with a hash.
openflange resolveok: 9 references locked in openflange.lock.yaml (9 added, 0 changed)Show openflange.lock.yaml
# Generated by openflange resolve. Commit this file.
spec: openflange.org/lock/v0.1
dependencies:
"./":
resolved: "."
version: "0.1.0"
revision: null
integrity: "sha256-986f72ab909d3d8572acc20f97d4509847b4f7cbb6624c657ed2b95a7e7353a7"
dependencies:
- "./pipes/total-per-group"
- "std:cast"
- "std:csv-decode"
- "std:csv-encode"
- "std:filter"
- "std:map"
- "std:validate-schema"
- "std:window"
"./pipes/total-per-group":
resolved: "pipes/total-per-group"
version: "0.1.0"
revision: null
integrity: "sha256-bbbd35fdcece9a55ca0aa8e0ffcc184b061e714bdbeacac52a36e41b5ff7f6bd"
"std:cast":
resolved: "std:cast@0.1.0"
version: "0.1.0"
revision: null
integrity: "sha256-97e37d1ac53ce0707419412ccf3580d74b55a510a821ffcb27e7d266712c410e"
"std:csv-decode":
resolved: "std:csv-decode@0.1.0"
version: "0.1.0"
revision: null
integrity: "sha256-1353928181578da854dbc4a56987db084a0defea91ab5da8311edd82a8a41e75"
"std:csv-encode":
resolved: "std:csv-encode@0.1.0"
version: "0.1.0"
revision: null
integrity: "sha256-44a6130259913e1eb9deace1b7c9168dfec6a9a64fa8bdb2bc410391c7a48a2a"
"std:filter":
resolved: "std:filter@0.1.0"
version: "0.1.0"
revision: null
integrity: "sha256-1cdf1024f705cc88d3cbfc588efcea274af5b8dd6e7691f45853ae9d0f06e716"
"std:map":
resolved: "std:map@0.1.0"
version: "0.1.0"
revision: null
integrity: "sha256-52f5564ae491cbeec79cdd4182fe7c64fadc2e7d87f981f4888be3a0971dea2d"
"std:validate-schema":
resolved: "std:validate-schema@0.1.0"
version: "0.1.0"
revision: null
integrity: "sha256-e24f74f04235b3855bcff81a3a671bc212fa65e555b1b0cb97cc51a708f521f6"
"std:window":
resolved: "std:window@0.1.0"
version: "0.1.0"
revision: null
integrity: "sha256-4b9a1df43868f4957c5ca40dda9f1516e4087e80571e2bd63de7628b64dce5d8"Commit openflange.lock.yaml. With --locked the runner refuses anything that differs from it. Here totals=- sends the CSV to stdout:
openflange run . --locked --input csv=orders.csv --output totals=- --output rejected=rejected.ndjsoncustomer,orders,total_cents
ada,2,4200
bob,2,2550
cy,1,450
completed in 2ms — totals: 1 chunk, rejected: 3 recordsNow change one byte of your step and run the same command again:
printf '# edited\n' >> pipes/total-per-group/total.star
openflange run . --locked --input csv=orders.csv --output totals=- --output rejected=rejected.ndjsonE_LOCK: reference "./pipes/total-per-group" does not match openflange.lock.yaml: ./pipes/total-per-group/OPENFLANGE.md now hashes to sha256-6cee713922d0…, the lockfile has sha256-bbbd35fdcece… (pipeline.yaml, at nodes.total.pipe)
hint: run `openflange update ./pipes/total-per-group` if the change is intendedExit status 2: nothing ran. Undo the edit before you go on. When a change is intended, openflange update moves the lock entry. More in Lockfiles.
4. Test it
A portable test is a YAML file next to the pipe: what goes in and what must come out. It travels with the pipeline, so whoever runs it next can check it first. This one feeds the job a small CSV and checks both outputs, an empty file, sums too large for a float, and the two ways the job must fail.
spec: openflange.org/test/v0.1
pipe: ..
tests:
- name: cleans names, routes bad rows, totals paid orders per customer
inputs:
csv:
text: |
order_id,customer,day,amount_cents,status
1, Ada ,2026-12-01,1000,paid
2,bob,2026-12-01,550,paid
3,ADA,2026-12-02,3200,paid
4,bob,2026-12-02,12.5,paid
5,bob,2026-12-02,900,refunded
expect:
outputs:
totals: {text: "customer,orders,total_cents\nada,2,4200\nbob,1,550\n"}
rejected:
count: 1
schema:
type: object
required: [item, errors]
properties:
item: {type: object, properties: {order_id: {const: "4"}}}
errors: {type: array, minItems: 1, items: {type: object, required: [path, message]}}
- name: a header row alone gives empty output
inputs:
csv: {text: "order_id,customer,day,amount_cents,status\n"}
expect:
outputs:
totals: {text: ""}
rejected: {count: 0}
- name: large totals stay exact
inputs:
csv:
text: |
order_id,customer,day,amount_cents,status
1,ada,2026-12-01,9007199254740993,paid
2,ada,2026-12-02,9007199254740993,paid
expect:
outputs:
totals: {text: "customer,orders,total_cents\nada,2,18014398509481986\n"}
- name: without a rejected consumer a bad row fails the run
inputs:
csv: {text: "order_id,customer,day,amount_cents,status\n1,ada,yesterday,1000,paid\n"}
expect:
status: failed
error: {code: E_RUNTIME}
outputs:
rejected: {disabled: true}
- name: a ragged CSV row is a format error
inputs:
csv: {text: "order_id,customer,day,amount_cents,status\n1,ada\n"}
expect:
status: failed
error: {code: E_FORMAT}Your own step has a test of its own, so it can be reused without the rest of the job.
spec: openflange.org/test/v0.1
tests:
- name: one record per frame
inputs:
groups:
values:
- window: {index: 0, partition: ada, start: 0, end: 1, final: true, partial: true}
items: [{amount_cents: 1000}, {amount_cents: 3200}]
- window: {index: 0, partition: bob, start: 0, end: 0, final: true, partial: true}
items: [{amount_cents: 550}]
expect:
outputs:
totals:
values:
- {customer: ada, orders: 2, total_cents: 4200}
- {customer: bob, orders: 1, total_cents: 550}
- name: an amount that is not an integer fails the run
inputs:
groups:
values:
- window: {index: 0, partition: ada, start: 0, end: 0, final: true, partial: true}
items: [{amount_cents: "1000"}]
expect:
status: failed
error: {code: E_RUNTIME}Run both:
openflange test . ./pipes/total-per-grouptests/orders-etl.test.yaml
ok cleans names, routes bad rows, totals paid orders per customer
ok a header row alone gives empty output
ok large totals stay exact
ok without a rejected consumer a bad row fails the run
ok a ragged CSV row is a format error
pipes/total-per-group/tests/total-per-group.test.yaml
ok one record per frame
ok an amount that is not an integer fails the run
ok 7 tests passed in 2 files (40ms)5. Swap a step, keep the rest
The aggregate above keeps the paid orders in memory until the input ends: std:window grouped by customer, with at most 1,000,000 orders per customer and 10,000 customers. That is right for a file of this kind and wrong for a hundred million rows.
For real volumes the aggregate belongs in a database or in R, and that is a change to two nodes, not to the job. Replace group and total with one node that runs a GROUP BY. The repository has such pipes: a DuckDB SQL query as a pipe and an R script as a pipe. Cleaning, validation, the lockfile and the tests keep their shape.
Not run for this page
The DuckDB and R variants of the aggregate were not run for this example, and no output is shown for them. The aggregate in steps 1 to 4 is the one that ran.
6. Batch the expensive steps
Every step of this pipeline runs inside the runner, so there is nothing to batch. That changes when a step lives in another process — an R or Python script, a database command-line tool, a call to a paid API — and a round trip per record becomes the cost.
Such a pipe declares batch mode in its manifest. The runner then hands it many records at a time, as one line or one file per batch, and the pipeline around it does not change:
batch:
maxItems: 50000
maxWaitMs: 1000
delivery: fileFrom examples/batch-file-duckdb/OPENFLANGE.md in the repository. It needs the duckdb command, so it was not run for this page.
Batch boundaries carry no meaning: batches are cut by size and time. A step that works row by row is safe to batch. An aggregate is not, because it would return one partial total per batch. The design and its reasons are in RFC 0003.
7. Schedule it yourself
OpenFlange is not a scheduler. It has no clock, no queue and no retry policy. A run starts when something calls the command and ends with an exit status: 0 completed, 1 failed, 2 nothing ran. Run it from cron, CI or your orchestrator.
Two illustrations of calling the CLI follow. They are not part of the example and were not run for this page; the paths and names are placeholders.
# crontab -e: every night at 02:15. A crontab entry is one line.
PATH=/usr/local/bin:/usr/bin:/bin:/home/etl/go/bin
ETL=/srv/orders-etl
OUT=/data/out
15 2 * * * cd $ETL && openflange run . --locked --input csv=/data/in/orders.csv --output totals=$OUT/totals.csv --output rejected=$OUT/rejected.ndjson >> /var/log/orders-etl.log 2>&1The same in GitHub Actions, pinned to release v0.0.1:
name: orders-etl
on:
schedule: [{cron: "15 2 * * *"}]
workflow_dispatch:
jobs:
run:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with: {go-version: stable}
- run: go install github.com/openflange/openflange-go/cmd/openflange@v0.0.1
- run: openflange test . ./pipes/total-per-group
- run: openflange run . --locked --input csv=orders.csv --output totals=totals.csv --output rejected=rejected.ndjson
- uses: actions/upload-artifact@v4
with:
name: orders-etl
path: |
totals.csv
rejected.ndjsonWhat OpenFlange is not
- Not a scheduler. Something else decides when a run starts and what happens when it fails. OpenFlange gives that something one command and an honest exit status.
- Not a warehouse. It moves and transforms records and stores nothing. The file, database or warehouse at either end is yours.
- Not a catalogue of hundreds of connectors. The standard library is small on purpose: files, CSV, JSON, filtering, casting, validation, windows. A source or sink that is missing is a pipe you write, in the language you already use.
What it does solve is one problem: an ETL step locked inside one tool. For the standard behind this page see ETL on openflange.org; for finding and publishing pipes see ETL on openflange.com.
Verified with openflange 0.0.1 (go1.27.1 linux/amd64) built from openflange-go commit 11cf8cc5378d70858724b16aa937d7f3b98c085d. The site’s tests compare every file and output on this page with the example byte for byte.