Run Query
POST/v1/query
Run an inline alias-only SQL query across the caller's own datasets.
-
datasetIds(plural, OPTIONAL):- Provided: each id resolves to that dataset's alias; the SQL joins the
aliases. Deny-don't-drop — if the key is not authorized for EVERY id, the
whole query is rejected (403
query_dataset_forbidden), never executed against the granted subset. - Omitted: the server INFERS the set from the aliases the SQL
references (each resolved to a dataset by
clean_sql_namefor the calling account), then applies the SAME authorization. An alias that matches no dataset in the account → 400query_dataset_unresolved. An inferred dataset the key isn't granted is still rejected (403) — inference is a DX convenience, NOT an authorization relaxation.
- Provided: each id resolves to that dataset's alias; the SQL joins the
aliases. Deny-don't-drop — if the key is not authorized for EVERY id, the
whole query is rejected (403
-
Dataset readiness: only a
READYdataset has an Iceberg table behind it. A participating dataset still ingesting (PENDING/DOWNLOADING/PROCESSING) → 400query_dataset_not_ready; one whose ingestion failed (FAILED) → 400query_dataset_failed. Both name the dataset and itsprocessingStatus, in bothbackendandwasmmodes. -
sql: inline, alias-only. Physical tables / DDL / file+remote readers are rejected by the embed SQL validator (403embed_sql_invalid). -
params: optional pass-through column filters, bound as escaped literals (never string-interpolated). A filter on a phantom column fails closed (403embed_filter_invalid). -
type(Phase 208):backend(default) orwasm.wasmasks for a PLAN instead of rows: the rewritten SQL plus one presigned Parquet extract per participating dataset, which the caller runs locally in DuckDB-WASM. Authorization, alias-only validation and filter injection ALL still happen server-side, in that order, BEFORE the capability check — asking for wasm cannot skip a single gate.- If any participating dataset is not wasm-capable (no Iceberg snapshot,
or an extract over
WASM_EXTRACT_MAX_BYTES), the query executes server-side exactly as today and the response reportsmode: "backend"with afallbackReason. Never a silent downgrade.
-
Live datasets (served from their connection, no copy): when every dataset named is live, the query runs on the customer's own database and the response says
mode: "live", withasOf(when the statement was sent) andcached(whether this answer came from the result cache).dialectabsent: the same DuckDB SQL over aliases as everywhere else, translated to the source's dialect. DuckDB-only constructs the source cannot express are refused at planning time, naming the node.dialectset (postgres): the source database's own SQL, written against its tables — still parsed, read-only validated and capped, never forwarded as a string. Native SQL binds no alias, soparamscannot filter it, and it reaches whatever the connection's database role can read: Creator/Admin only, on a connection the caller may use; anyone else gets 404connection_not_found.datasetIdsis required (there is no alias to infer from).maxAgeis the oldest cached answer accepted, in seconds, never more than the smallestcacheTtlSecondsamong the datasets;0runs on the source now and refreshes the cache.datasetIdsmay hold live and copied datasets together: each statement runs on the lane of the datasets its SQL names. One statement cannot read a live and a copied dataset together (400live_and_copied_datasets_cannot_mix), every live dataset must run on one connection, andtype: "wasm"falls back to the live run with afallbackReason— the browser lane cannot reach a database.- The lane is rolled out per account: 409
live_query_disabledwhile it is not open to yours. A source that times out, refuses the statement or returns more than 64 MB answers 400live_query_failedwith the source's own (sanitized) sentence.
-
Lane policy: an account declares which server lanes it pays for. A copied dataset spends
extract, a live onelive; an account without that lane gets 403QUERY_LANE_NOT_PERMITTED(body carriesallowedQueryLanesandlaneRequired) before any row is read. Awasmplan runs in the caller's browser and spends nothing.
Returns typed columnar { columns:[{name,type}], rows } — or, in wasm mode,
{ mode:"wasm", plan:{ sql, sources } }. mode always states what the
query ACTUALLY ran as; durationMs is the server time the answer took.
Metered through the existing usage/credits mechanism in
every lane. Result transport (inline vs presigned object-storage blob) is an
internal decision hidden by the SDK's query().
Request
Responses
- 200
- 404
- 422
Successful Response
Not found
Validation Error