Steps and formulas
A steps node applies operations to one input, in order. Each is a closed operation, {"op": ..., ...}, that names the columns it reads, so a missing column is caught before anything runs and a step is never SQL anyone but a sql step’s author wrote. A node holds at most 500 steps.
{"id": "clean", "kind": "steps", "input": "sales", "steps": [
{"op": "trim_val", "columns": ["product"]},
{"op": "title_case", "columns": ["category"]},
{"op": "dedupe", "columns": ["order_id"]},
{"op": "fill_empty", "column": "qty", "value": 1},
{"op": "add_column", "column": "revenue", "formula": "round(qty * unit_price, 2)"}
]}
The run records each step: {"step": 3, "op": "dedupe", "rows": 5, "said": "removed 1 row repeated"}, with changed for a step that changes values in place.
Columns
op | Fields | Does |
|---|---|---|
rename_column | column, to | renames it |
retype_column | column, type, format | a new type, kept only if every value converts without loss, or the run fails saying how many do not. Text to a date or timestamp may name its format in strptime’s form: "%d/%m/%Y" |
remove_columns | columns | drops them |
reorder_columns | columns | these first, in this order, the rest after as they were |
add_column | column, formula | a new column computed by a formula |
update_column | column, formula | the column computed again; the formula may read it, and its type is the formula’s |
Rows
op | Fields | Does |
|---|---|---|
filter | formula | keeps the rows the formula is true for |
sort | by: [{"column", "desc"}] | sorts; desc defaults to false |
dedupe | columns | keeps the first row of each set equal on these columns, or on all of them when none are named, in the order the rows came |
fill_empty | column, value | an empty value becomes value, of the column’s type |
fill_down | columns | an empty value becomes the nearest one above it: a label a spreadsheet wrote once for the rows below |
Values
op | Fields | Does |
|---|---|---|
find_and_replace_val | column, find, with, whole | text found and replaced within each value, or only a whole value with whole: true |
remap_val | column, values: [{"from", "to"}] | whole values made others: NY to New York |
trim_val | columns | spaces trimmed from both ends |
upper_case, lower_case | columns | GROCERY STORE, grocery store |
title_case | columns | Grocery Store |
snake_case | columns | grocery_store; GroceryStore too |
camel_case | columns | groceryStore |
The trim and case steps and find_and_replace_val work on text columns, and are refused on any other.
Shape
op | Fields | Does |
|---|---|---|
group | by, aggregates: [{"column", "fn", "as"}] | a row per set of values of by, and each aggregate over it. fn is sum, min, max, avg, count or count_distinct; count with no column counts rows |
unpivot | columns or keep, name, value, keep_empty | columns made rows: each row becomes one per column unpivoted, its name in name and its value in value, the other columns repeated. Name the columns to unpivot, or the ones to keep, so a column a later file adds (a new month) is unpivoted too. An empty value makes no row unless keep_empty |
sql | query | a query over the step before, read as input (below) |
{"op": "unpivot", "keep": ["store"], "name": "month", "value": "amount"}
turns store,jan,feb / A,1,2 / B,3, into:
[["A", "jan", 1], ["A", "feb", 2], ["B", "jan", 3]]
{"op": "group", "by": ["store_id"], "aggregates": [{"column": "revenue", "fn": "sum", "as": "revenue"}, {"fn": "count", "as": "orders"}]}
count and count_distinct are integers; min and max keep the column’s type.
SQL
A sql step reads the step before it as input, and nothing else:
{"op": "sql", "query": "SELECT *, unit_price * 1.08 AS price_with_tax FROM input"}
A sql node reads several nodes, each under the alias it gives:
{"id": "q", "kind": "sql", "inputs": {"s": "by_store", "p": "promos"},
"query": "SELECT s.store_id, s.revenue, s.orders, p.promo, s.revenue * (1 - coalesce(p.discount, 0)) AS net FROM s LEFT JOIN p USING (store_id) ORDER BY s.store_id"}
Previewed, from a dataset and the push source on Sources:
{"node": "q",
"columns": [{"name": "store_id", "role": "dimension", "type": "integer"},
{"name": "revenue", "role": "measure", "type": "decimal(2)"},
{"name": "orders", "role": "measure", "type": "integer"},
{"name": "promo", "role": "dimension", "type": "text"},
{"name": "net", "role": "measure", "type": "decimal(4)"}],
"rows": [[101, "41.76", 2, "Fall harvest", "37.5840"], [202, "3.25", 1, null, "3.2500"], [999, "3.78", 1, null, "3.7800"]]}
It is DuckDB SQL, run as a black box, and checked by DuckDB’s own parser before it runs, so no quoting hides a call:
- One
SELECT, reading its inputs and the tables its ownWITHmakes, and no other table, catalog or table function butrange,generate_seriesandunnest. - The same query every run. A function whose answer is not the data’s (
now(),current_date,random(),uuid()and the like) is refused;today()in a formula is the one clock a pipeline has. So is a function that runs other SQL or reads the engine or its host (query,getenv,current_setting,glob,duckdb_*). - Its columns are what DuckDB answers, each cast to a type a dataset has.
- Bounded: at most 64 KiB of SQL, 60 seconds, and the engine’s memory and threads. The engine has external access off: no file, no URL.
{"code": "invalid", "node": "b",
"message": "step 1 (sql): random is not the same on every run, and a pipeline runs again on every new file; use a column of the data, or a formula step's today()"}
{"code": "invalid", "node": "b",
"message": "step 1 (sql): read_csv() is not a table a query here reads; it reads input, and range(), generate_series() and unnest()"}
Formulas
add_column, update_column and filter take a formula, and so does the filter of a page of rows. It is data prep’s own small, typed language, compiled to the engine’s SQL; it is not the model’s SQL, nor the query API’s expression language.
round(qty * unit_price, 2)
category <> 'Test' and qty is not null
if(region in ('NE', 'MW'), 'north', 'south')
[order date] - month
upper(region) & ':' & units
formula := or
or := and ("or" and)*
and := not ("and" not)*
not := "not" not | test
test := sum (cmp sum | "is" ["not"] "null" | ["not"] "in" "(" list ")")?
cmp := "=" | "!=" | "<>" | "<" | "<=" | ">" | ">="
sum := product (("+" | "-" | "&") product)*
product := unary (("*" | "/" | "%") unary)*
unary := "-" unary | atom
atom := number | string | "true" | "false" | "null"
| column | function "(" list? ")" | "(" formula ")"
column := name | "[" any name "]"
string := '...' | "..." a quote doubled is the quote
- A column is a bare name, or any name in brackets:
[order date]. Names are case-insensitive. &joins text.+ - * / %are arithmetic; a date plus a number is a date, and a date minus a date is a number of days.- It is typed before it runs. Every function takes the types it says and gives the type it says, so a formula’s type is known and every result is cast to it:
amount * unitson adecimal(2)and an integer isdecimal(2),units / 2isdouble, a comparison isboolean. A text literal does not compare with a date: writeorder_date >= to_date('2026-08-01'). - Out of range is null, not a failed run:
units / 0,sqrt(-1),to_date('soon'). today()andnow()are the time the run was pinned to, the same for every row and every step of one run, and recorded in the lineage aspinned_at.- At most 4,096 characters, nested at most 64 deep.
A formula that does not type is refused before the run, by node and step:
{"code": "invalid", "node": "clean", "message": "step 7 (add_column): in formula `upper(qty)`: upper() takes text, not integer"}
Functions
Only these. A name not here is not a function: read_csv('/etc/passwd') is refused with the list.
| Kind | Functions |
|---|---|
| Text | upper, lower, trim, title_case, snake_case, camel_case, length, left(x, n), right(x, n), substr(x, start, len?), replace(x, find, with), concat(...), contains(x, y), starts_with(x, y), ends_with(x, y), split_part(x, delimiter, index) |
| Numbers | abs, sign, round(x, places?), floor, ceil, power(x, y), sqrt, ln, exp, log10, least(...), greatest(...) |
| Dates | today(), now(), year, month, day, quarter, week, weekday (ISO, Monday is 1), date_trunc(part, x), date_diff(part, a, b), make_date(y, m, d); a part is 'year', 'quarter', 'month', 'week' or 'day' |
| Logic | if(condition, then, else?), ifs(c1, r1, c2, r2, ..., default?), switch(x, v1, r1, v2, r2, ..., default?), coalesce(...), nullif(a, b) |
| Conversions | to_text, to_number(x, mark?), to_integer(x, mark?), is_number(x, mark?), to_date(x, how?), is_date(x, how?), to_timestamp(x, how?), to_boolean |
round(x, places) keeps a decimal of that many places; round(x), floor and ceil give integers. replace() is refused past 64 KiB of result, so nesting cannot build a huge value.
Conversions
The conversions read values the way people write them, and give null for what does not read, never a guess:
to_number(x)drops a currency symbol or a three-letter code at either end, spaces and the thousands separator:'$1,204.50'is1204.5,'(500)'is-500,'12%'is0.12, each adecimal(6).to_number(x, ',')reads a decimal comma:'1.204,50'.to_integergives a whole number or null:1.5is not an integer rounded.to_date(x)reads every unambiguous way a date is written: ISO dates and timestamps,2026.09.07,20260907,202609,2026-09, and a month’s name (7 Sep 2026,September 7, 2026,Sep 2026). A date that does not exist (2026-13-01) is null. The second argument says more:'dmy'for31/01/2026,'mdy'for01/31/2026,'excel'for a spreadsheet’s serial number, or a strptime format such as'%d/%m/%Y'.to_timestamp(x, how?)reads asto_datedoes, at midnight, and with a time where the value has one.to_boolean(x)readstrue/t/yes/y/1andfalse/f/no/n/0, in any case.is_numberandis_datesay whether the conversion would succeed:filterwithnot is_date(order_date, 'dmy')finds the rows that would not.
Next steps
- Edits: changes by hand, by key
- Graphs and runs: where steps run