Solidafy DSL
DSL transforms
Every transform you can chain onto a source, with its signature, options and a short example. If you are new to the DSL, read the DSL overview first.
Transforms run in the order you write them, and each one sees only the columns the previous step produced. Signatures below use col for a column name, expr for an expression (see Functions) and [...] for a list.
Filtering rows
filter
.filter(expr)
Keeps the rows where expr is true.
source("github.pull_requests")
.filter(state == "merged" and base_branch in ["main", "master"])
.filter(merged_at is not null)
Use is null and is not null for null checks; col == null never matches.
where
.where(col, value), .where(col, "op", value), .where(col, [v1, v2])
A one-column filter without writing a full expression. With two arguments it tests equality; with a list it tests membership.
| Operator | Meaning |
|---|---|
"==", "=" | equal |
"!=" | not equal |
">", ">=", "<", "<=" | comparison |
"contains", "starts_with", "ends_with" | substring tests |
"matches", "~", "regex" | regular expression match |
source("deploys.events").where(environment, "production")
source("deploys.events").where(duration_s, ">", 600)
source("deploys.events").where(service, "starts_with", "payments-")
source("deploys.events").where(status, ["failed", "rolled_back"])
Warning: An operator not in this table is treated as
==. Check the spelling.
null
.null(col)
Keeps rows where col is null.
source("github.pull_requests").null(merged_at)
not_null
.not_null(col)
Keeps rows where col is not null.
source("github.pull_requests").not_null(first_review_at)
since
.since(col, "duration"), .since(col, "duration", previous: true)
Keeps rows where col is within the given window, ending now. col can be @time.
Durations are a number plus a unit: s, m (minutes), h, d, w, for example "30m", "24h", "7d", "2w". Named periods are also accepted:
| Period | Covers |
|---|---|
"mtd" | start of this month to now |
"last_month" | the whole previous calendar month |
"qtd" | start of this quarter to now |
"last_quarter" | the whole previous quarter |
"ytd" | start of this year to now |
"last_year" | the whole previous calendar year |
"last_3_months", "last_6_months", "last_12_months" | that many whole months back |
previous: true moves the window back by its own length, which gives you the comparison period: .since(merged_at, "30d", previous: true) covers 60 to 30 days ago.
source("cloud.costs").since(usage_date, "mtd")
source("cloud.costs").since(usage_date, "mtd", previous: true)
before
.before(col, "duration")
Keeps rows older than the duration (same formats as since). With a named period, the cut-off is the start of that period.
source("github.pull_requests").filter(state == "open").before(created_at, "30d")
between
.between(col, "start", "end"), .between(col, "start", "end", previous: true)
Keeps rows where col is between two dates or timestamps, both ends included. previous: true shifts the range back by its own length.
source("cloud.costs").between(usage_date, "2026-09-01", "2026-09-30")
Note: A bare date means midnight. To include all of the last day on a timestamp column, use the next day or a full timestamp such as
"2026-09-30T23:59:59".
Choosing and computing columns
select
.select([expr, expr as alias, ...])
Keeps only the listed columns, in that order. Items can be expressions with an alias. Columns you leave out are gone for the rest of the chain.
source("github.pull_requests")
.select([id, repo, author.login as author, additions + deletions as lines_changed, merged_at])
A nested field without an alias is named with underscores: author.login becomes author_login.
add
.add([expr as name, ...]), also written .with_columns([...])
Adds computed columns and keeps all existing ones. Every item needs an alias. Items are applied left to right, so a later item can use an earlier one, and reusing an existing name replaces that column.
source("github.pull_requests")
.add([
hours_between(created_at, merged_at) as cycle_hours,
case(when: additions + deletions <= 50 then "S", when: additions + deletions <= 400 then "M", else: "L") as size
])
drop
.drop([col, ...])
Removes columns.
source("raw.deployments").drop([payload, _row_hash])
rename
.rename([old as new, ...])
source("github.pull_requests").rename([user_login as author, html_url as url])
cast
.cast([col as type, ...])
Changes column types in place. Types: integer (64-bit), int64, float64, string, boolean, date, timestamp. A value that cannot be converted fails the query; for messy data use the try_cast method instead (see Type conversion).
source("raw.ai_usage").cast([input_tokens as int64, cost_usd as float64, ts as timestamp])
coalesce
.coalesce(prefer: col, fallback: col)
Replaces nulls in prefer with the value from fallback, in place.
source("enrich.developers").coalesce(prefer: display_name, fallback: github_handle)
fill_null
.fill_null(col, value)
Replaces nulls in one column with a literal, in place.
source("github.pull_requests").fill_null(review_comments, 0)
abs
.abs(col) replaces a column with its absolute value.
source("cloud.cost_changes").abs(delta)
round
.round(col, decimals) rounds a column in place.
source("cloud.costs").round(cost, 2)
lower
.lower(col) lowercases a text column in place.
source("enrich.developers").lower(email)
upper
.upper(col) uppercases a text column in place.
source("jira.issues").upper(project_key)
trim
.trim(col) strips leading and trailing whitespace in place.
source("enrich.developers").trim(email)
format
.format(col, "type")
Replaces a column with a display string. "currency" prefixes $, "percent" multiplies by 100 and appends %, and anything else is a date pattern using YYYY, YY, MM, DD, HH, mm and SS.
source("deploys.events").format(deployed_at, "YYYY-MM-DD HH:mm")
split
.split(col, "delimiter", index)
Splits text and adds the piece at index (counting from 0) as col_split.
source("github.pull_requests").split(repo_full_name, "/", 1)
// adds repo_full_name_split: "api" from "acme/api"
extract
.extract(col, "part")
Adds a date part as col_part. Parts: year, month, day, hour, minute, second, dow (or dayofweek), doy (or dayofyear), week, quarter.
source("deploys.events").extract(deployed_at, "dow")
// adds deployed_at_dow
bucket
.bucket(col, [boundaries])
Adds col_bucket with a text label per range. [50, 200, 500] gives <50, 50-200, 200-500 and >=500.
source("github.pull_requests")
.add([additions + deletions as lines])
.bucket(lines, [50, 200, 500])
ratio
.ratio(numerator, denominator)
Adds numerator_ratio, which is null when the denominator is null or zero.
source("ci.daily_runs").ratio(failed_runs, total_runs)
// adds failed_runs_ratio
Sorting and limiting
sort
.sort([col, col: desc, ...])
Sorts by one or more columns, ascending unless you write : desc. Nulls come first in ascending order and last in descending order.
source("cloud.costs").sort([usage_date: desc, cost: desc])
limit
.limit(n), .limit(n, offset: m)
source("github.pull_requests").sort([merged_at: desc]).limit(20, offset: 40)
top
.top(col, n) sorts descending (nulls last) and keeps the first n rows.
source("ai.usage_daily").top(cost_usd, 10)
bottom
.bottom(col, n) sorts ascending and keeps the first n rows. Nulls sort first here, so filter them out if they matter.
source("ci.pipelines").not_null(success_rate).bottom(success_rate, 5)
first
.first(col, n) sorts ascending with nulls last and keeps n rows.
source("deploys.events").first(deployed_at, 1)
last
.last(col, n) sorts descending and keeps n rows.
source("deploys.events").last(deployed_at, 5)
preview
.preview(), .preview(limit: n) keeps the first n rows (100 by default).
source("raw.github_events").preview(limit: 20)
Removing duplicates
dedupe
.dedupe([key, ...]), .dedupe([key, ...], keep: strategy)
Keeps one row per key combination.
keep: | Row kept |
|---|---|
first (default) | the first row as read |
last | the last row as read |
latest_by(col), max_by(col) | the row with the largest col |
earliest_by(col), min_by(col) | the row with the smallest col |
source("raw.github_pull_requests").dedupe([id], keep: latest_by(_extracted_at))
Raw tables collect a new copy of a record on every sync, so dedupe with latest_by(_extracted_at) is the usual first step when you read one.
distinct
.distinct(col) returns the distinct values of one column, as a one-column result.
source("enrich.developers").distinct(team)
Aggregating
group_by
.group_by([col, ...])
Sets the grouping for the next .agg(). Items are columns or expressions, but you cannot alias them here, so compute derived keys with .add() first. An empty list is a syntax error; for a grand total leave group_by out.
source("cloud.costs")
.add([date_trunc("month", usage_date) as month])
.group_by([month, service])
.agg([sum(cost) as monthly_cost])
agg
.agg([aggregate as name, ...])
Computes aggregates per group, or over the whole input when there is no group_by. The result has the group columns plus one column per aggregate. Without an alias, the column is named after the function and column, for example sum_cost, or count for count().
Inside .agg() you can do arithmetic between aggregates and wrap them in round, abs, ceil, floor or coalesce:
source("github.pull_requests")
.filter(state == "merged")
.group_by([repo])
.agg([
count() as merged,
count_distinct(author) as authors,
round(sum(review_count) * 1.0 / count(), 2) as reviews_per_pr,
percentile_cont(hours_between(created_at, merged_at), 50) as median_cycle_hours
])
The aggregate functions are listed in Functions.
count
.count(), .count(col)
Returns one row with a count column: all rows, or non-null values of col.
source("github.pull_requests").filter(state == "open").count()
stats
.stats(col) returns one row with count, min, max, mean and stddev for a column.
source("ci.job_runs").stats(duration_s)
describe
.describe() returns one row with <col>_count, <col>_min, <col>_max and <col>_mean for every numeric column.
source("ai.usage_events").describe()
percentile
.percentile(col, p) returns one row with the approximate pth percentile as col_p<p>.
source("ci.job_runs").percentile(duration_s, 95)
// returns duration_s_p95
percentiles
.percentiles(col, [p, ...]) does the same for several percentiles at once.
source("ci.job_runs").percentiles(duration_s, [50, 90, 99])
histogram
.histogram(col, [boundaries]) returns one row per range with bucket and count columns. Labels follow the same rules as bucket.
source("github.pull_requests")
.add([hours_between(created_at, merged_at) as cycle_hours])
.histogram(cycle_hours, [4, 24, 72, 168])
error_rate
.error_rate(col), .error_rate(col, "value")
Returns one row with error_rate: the share of rows that count as errors. On a boolean column true is an error; otherwise rows equal to "value" (default "error") are.
source("deploys.events").since(deployed_at, "7d").error_rate(status, "failed")
resample
.resample(col, "interval"), followed by .agg([...])
Truncates a timestamp to the interval and groups by it. The truncated value keeps the original column name. Intervals: "1s", "1m", "1h", "1d", "1w", "1mo", "1y" (or "second", "minute", "hour", "day", "week", "month", "year").
source("ai.usage_events")
.resample(ts, "1d")
.agg([sum(input_tokens + output_tokens) as tokens, sum(cost_usd) as cost])
Window calculations
The shortcut transforms below each add one column. Their order: is always ascending, and partition: takes a single column. For descending order, several partition columns or several window columns at once, use window.
lag
.lag(col, n, order: col, partition: col) adds col_lag_<n>, the value n rows earlier.
source("cloud.daily_costs").lag(cost, 1, order: day, partition: service)
lead
.lead(col, n, order: col, partition: col) adds col_lead_<n>, the value n rows later.
source("deploys.events").lead(deployed_at, 1, order: deployed_at, partition: service)
diff
.diff(col, order: col, partition: col) adds col_diff, the change from the previous row.
source("cloud.daily_costs").diff(cost, order: day, partition: service)
change
.change(col, order: col, partition: col) adds col_change, the percentage change from the previous row (null when the previous value is 0).
source("cloud.daily_costs").change(cost, order: day, partition: service)
cumsum
.cumsum(col, order: col, partition: col) adds col_cumsum, a running total.
source("ai.usage_daily").cumsum(cost_usd, order: day, partition: team)
rolling
.rolling(col, size, "func", order: col, partition: col)
Adds col_rolling_<func>_<size>: the function over the current row and the size - 1 rows before it. Functions: "sum", "avg" (or "mean"), "min", "max", "count".
source("cloud.daily_costs").rolling(cost, 7, "avg", order: day, partition: service)
// adds cost_rolling_avg_7
rank
.rank(col, order: col, partition: col) adds a rank column (ties share a rank, with gaps after them), ranked by order: ascending.
source("ci.pipelines").rank(duration_s, order: duration_s, partition: repo)
dense_rank
.dense_rank(col, order: col, partition: col) adds a dense_rank column (ties share a rank, no gaps).
source("ci.pipelines").dense_rank(duration_s, order: duration_s)
row_number
.row_number(order: col, partition: col) adds a row_number column numbering rows from 1. order: is required.
source("deploys.events").row_number(order: deployed_at, partition: service)
window
.window(partition: [col, ...], order: [col: desc, ...])
Sets a window for the step right after it. Give at least one of the two options, in either order; a partition: list cannot be empty, so leave it out to treat all rows as one partition. order: also accepts a single column. The window applies to the next step only:
- Followed by
.add([...]): window functions in the list (lag,lead,row_number,rank,dense_rank,ntile,percent_rank,cume_dist,first_value,last_value,rolling_avg, andsum,avg,count,min,maxas running values) are computed over the window. Other expressions in the list are computed normally. - Followed by
.agg([...]): each aggregate is computed over the window and added as a column, without collapsing rows.
source("cloud.daily_costs")
.window(partition: [service], order: [day: asc])
.add([
lag(cost, 1) as prev_cost,
sum(cost) as running_cost,
rolling_avg(cost, 7) as cost_7d_avg
])
source("github.pull_requests")
.window(partition: [team], order: [merged_at: desc])
.add([row_number() as rn])
.filter(rn <= 3)
Note:
frame:is not supported and is rejected. Userolling_avg(col, n)or rolling for a sliding window.
Window functions can also be written inline with over: inside a plain .add(); see Window functions.
Combining tables
join
.join(right, on: condition, type: kind), .join(right, left_on: [col, ...], right_on: [col, ...], type: kind)
right is a table name in quotes, a source(...), or a variable. Kinds: inner, left, right, full, semi (left rows that have a match), anti (left rows that have no match). The kind can be quoted or not.
The condition is a column present on both sides (on: id), an equality (on: author == github_handle, left side first) or a list of equalities (on: [repo == repo_name, author == login]). left_on/right_on is the same thing written as two lists.
| Option | Meaning |
|---|---|
type: | join kind; see above |
prefix: "p_" | renames every right-side column except the join keys to p_<name>, which avoids clashes |
source("github.pull_requests")
.select([id, repo, author, merged_at])
.join("enrich.developers", left_on: [author], right_on: [github_handle], type: left, prefix: "dev_")
.select([id, repo, author, dev_team, merged_at])
When both sides use the same key name, the result has one copy of it. When the names differ, both key columns stay.
If both sides have other columns with the same name (every Solidafy table has _extracted_at, for example), select the columns you need before the join or use prefix:. To refer to a left-side column explicitly, give the starting source an alias and qualify the column with it:
source("github.pull_requests", as: "pr")
.join("enrich.developers", left_on: [author], right_on: [github_handle], type: left, prefix: "dev_")
.select([pr.id, pr.repo, pr._extracted_at as synced_at, dev_team])
The right side may hold several rows per key; each match becomes its own row. Dedupe the right side first if you want one match.
lookup
.lookup("name", col), .lookup("name", left_col = right_col)
A left join against a table registered in the query by name, such as a variable defined earlier. All right-side columns are added. For catalog tables, use join.
devs = source("enrich.developers").select([github_handle, team])
source("github.pull_requests").lookup("devs", author = github_handle)
enrich
.enrich("name", on: col), .enrich("name", on: left_col = right_col)
The same as lookup, written with on:.
devs = source("enrich.developers").select([github_handle, team])
source("github.pull_requests").enrich("devs", on: author = github_handle)
Reshaping
pivot
.pivot(index: [col, ...], columns: col, values: col, agg: func, fill_null: value)
Turns the distinct values of columns into columns of their own, filled with agg of values. agg is sum, avg, min, max, count, first or last. fill_null: is optional.
source("cloud.costs")
.add([strftime("%Y-%m", usage_date) as month])
.group_by([month, provider])
.agg([sum(cost) as cost])
.pivot(index: [month], columns: provider, values: cost, agg: sum, fill_null: 0)
unpivot
.unpivot(id_columns: [...], value_columns: [...], variable_name: "name", value_name: "name")
Turns columns into rows. The values are converted to floating point.
source("ai.usage_daily")
.unpivot(id_columns: [day, model], value_columns: [input_tokens, output_tokens], variable_name: "kind", value_name: "tokens")
unnest
.unnest(col)
Flattens nested data:
- Struct: each field becomes a column named
col_field. - List of structs: one row per element, each field as a column named after the field.
- List: one row per element.
- Map: one row per entry, with
keyandvaluecolumns.
source("raw.github_pull_requests")
.select([id, user, _extracted_at])
.unnest(user)
.select([id, user_login, user_type, _extracted_at])
.unnest() replaces the column it flattens, and any column you did not select before it is gone, so carry _extracted_at and your keys through the first .select().
explode
.explode(col), .explode(col, as: name)
One row per element of a list column; as: renames the result. On a struct column, fields become name_field.
source("github.pull_requests").explode(labels, as: label)
unpack
.unpack(col, ["key", "key" as name, ...])
Pulls keys out of a map column into columns. Without an alias, dots in the key become underscores.
source("otel.spans").unpack(resource_attributes, ["service.name", "deployment.environment" as env])
// adds service_name and env
Inspecting
schema
.schema() returns one row per column with column_name and data_type, instead of the data.
source("github.pull_requests").schema()
Monitoring
These transforms find the rows an alert should fire on, and usually end in .push() to send a message. They need time: on the source, and breach also needs granularity:. See Alerts for how to turn the result into a message.
by
.by([col, ...]) sets the grouping for the next breach or absent.
source("deploys.events", time: deployed_at, granularity: 5m).by([service])
breach
.breach(aggregate op value, for: duration)
Buckets rows by the source granularity and returns the groups where the condition held in every bucket of the last for: duration, with the aggregate as _agg_value. The condition is one aggregate compared with a value. for: is unquoted, for example 15m or 1h.
source("deploys.events", time: deployed_at, granularity: 5m)
.filter(status == "failed")
.by([service])
.breach(count() > 3, for: 15m)
.add([concat(service, ": repeated deploy failures") as text])
.select([text])
.push("slack-push", action: "send_message", webhook_path: "/services/YOUR/WEBHOOK/PATH")
absent
.absent(for: duration)
Returns the groups (or the whole input, without .by()) that have no rows newer than the duration, with their last time as _last_seen.
source("ci.job_runs", time: finished_at)
.by([pipeline])
.absent(for: 1d)
.add([concat(pipeline, ": has not run for a day") as text])
.select([text])
.push("slack-push", action: "send_message", webhook_path: "/services/YOUR/WEBHOOK/PATH")
Forecasting and anomalies
forecast
.forecast(col, horizon: n)
Fits a straight line through col in row order and appends n predicted rows. Every row gets _is_forecast; predicted rows also get col_lower and col_upper, a 95% band. Other columns are null in predicted rows. Sort the input first and keep it at one row per period. Only the linear method is available.
source("cloud.costs")
.add([date_trunc("day", usage_date) as day])
.group_by([day])
.agg([sum(cost) as daily_cost])
.sort([day: asc])
.forecast(daily_cost, horizon: 14)
anomaly
.anomaly(col, window: n), .anomaly(col, window: n, threshold: x)
Scores each row against the mean and standard deviation of the n rows before it (a z-score) and adds col_score (0 to 1), col_expected, col_deviation and col_is_anomaly. A row is an anomaly when it is more than threshold standard deviations away (default 3.0). Only the z-score method is available.
source("ai.usage_daily")
.sort([day: asc])
.anomaly(cost_usd, window: 14, threshold: 2.5)
.filter(cost_usd_is_anomaly)
Semantic search
embed
.embed([col, ...], as: name)
Joins the text of the listed columns and adds an embedding vector column. Use it in a pipeline that writes the result with .output(), so the embeddings are computed once. See Semantic search.
source("jira.issues")
.embed([summary, description], as: issue_embedding)
.output("silver.jira_issues", mode: replace)
find_similar
.find_similar("text", column: col, top: n, threshold: x)
Ranks rows by similarity to the text and adds _similarity, highest first. top: defaults to 10; threshold: (0 to 1) is optional.
source("silver.jira_issues")
.find_similar("flaky checkout test times out", column: issue_embedding, top: 5)
correlate
.correlate("ns.table", left: col, right: col, top: n, threshold: x)
For each row, finds the closest rows in another table by embedding similarity. Returns one row per match with the left columns, the right columns renamed to right_<name>, and _similarity; the two embedding columns are left out. top: defaults to 3.
source("silver.incidents")
.correlate("silver.jira_issues", left: incident_embedding, right: issue_embedding, top: 3, threshold: 0.5)
Machine learning
score
.score("model"), .score("model", as: col)
Scores every row with the latest version of a model you trained with .train() and adds the prediction as a decimal column, named <model>_prediction unless you give as:. A linear regression model predicts the target value; a logistic regression model gives the probability (0 to 1) that the target is true. All other columns are kept.
The rows must carry every feature column the model was trained on, as numbers with no nulls, or the query fails and names the column. A model name that was never trained fails with model not found.
source("features.customers")
.score("churn_risk", as: churn_prob)
.filter(churn_prob > 0.7)
Data quality and privacy
validate
.validate([check(expr, severity: error, name: "label"), ...])
Drops rows that fail an error check. See Data quality for the details.
source("raw.deployments").validate([check(id is not null, severity: error, name: "id_required")])
on_error
.on_error(quarantine: "ns.table") sets options for a following validate. See Data quality.
route
.route(errors: "ns.table", warnings: "ns.table") is accepted but has no effect. See Data quality.
pii
.pii(anonymize: [col with: action, ...], scan: [type, ...], scan_action: action)
Masks personal data before it goes further.
| Action | Result |
|---|---|
hash | MD5 hash of the value |
tokenize | tok_ followed by the MD5 hash |
mask | **** |
redact | [REDACTED] |
flag | leaves the value unchanged |
scan: looks through every text column for email, phone, ssn, credit_card or ip_address patterns and applies scan_action (default flag) to any column where it finds a match.
source("raw.jira_users")
.pii(anonymize: [email_address with: hash], scan: [email, phone], scan_action: redact)
History and change data
scd2
.scd2(keys: [...], track: [...])
Adds _row_hash, _valid_from, _valid_to and _is_current columns to the rows in hand. To keep real history in a table, use mode: scd2 on .output() instead; see SCD2.
cdc
.cdc(operation: col, before: col, after: col)
For change-data-capture records: drops rows whose operation is "d" (deletes), expands the after struct into columns, and removes the operation and before columns. The deletes: option is accepted but deletes are always dropped.
source("raw.orders_changes").cdc(operation: op, before: before, after: after)
