SQL examples
← All examplesSQL runs over one endpoint - POST /v1/tenants/:t/sql - and comes back as JSON rows keyed by column name. The 13 examples below each carry the schema TOML they need, a pre-seed insert, side-by-side cURL / Python / TypeScript / Go, the response shape, and notes on common mistakes.
All 13 execute today. ORDER BY, HAVING, window functions (including explicit ROWS frames), UPDATE, DELETE and both plain and recursive CTEs all run server-side. Each shape has bounds — RANGE frames take peer bounds only, a recursive CTE is UNION ALL and one CTE per statement, and windows cannot yet share a SELECT with a JOIN or GROUP BY. The per-example pages state the limits that apply.
Project specific columns from a single table. Read only the fields you need.
Equality predicate. The planner promotes it to an IndexScan when an index covers the column.
Match against a small set of literal values. Folded into a disjunction over equalities.
Range predicate on a numeric or string column. Inclusive on both bounds.
Combine rows that have a match on both sides. Hash-join on the equality.
Every row from the left side, plus matches from the right (null if no match).
Multiple aggregates in one pass. The hash aggregator buckets on the GROUP BY key.
ORDER BY (asc/desc), LIMIT and OFFSET all execute through the SQL translator today.
ROW_NUMBER, RANK, LAG and LEAD execute today, and so do explicit ROWS frames on the aggregates. RANGE takes peer bounds only.
Uncorrelated and correlated subqueries both execute - IN (SELECT), EXISTS / NOT EXISTS, and scalar forms.
UPDATE executes against the engine and returns rows_affected. (Earlier builds only translated.)
DELETE executes and returns rows_affected. Any supported predicate works, plus RETURNING.
Recursive CTEs walk a hierarchy to a fixed point: one CTE per statement, UNION ALL, depth and row capped.
CTEs, bind parameters, date_trunc time-bucketing, CASE and catalog introspection — the most recent additions, each shown against live output.