Skip to main content
The SDK has two query methods and one legacy one. queryRun reads, querySubmit writes, and both go through the query router, which picks the engine and machine size for you.

queryRun(sqlOrOptions)

Runs a query and returns the rows on the call. oleander parses the SQL, estimates how much data the referenced tables hold, and picks the engine (duckdb, polars, bloom) and machine size to match, so leave engine as auto unless you want a specific one. The choice and the reasoning behind it come back in engine_decision.
queryRun is read-only. SQL that could change data is rejected before the request goes out - use querySubmit for those.

Explain without running

Pass explain: true to see which engine a query would take, its estimated input size, and whether your plan allows it, without running anything or spending compute.
Do this before a query you expect to be large.

Polars scripts

Pass script instead of sql to run a Polars DataFrame script that assigns result, listing the tables it reads in tables. This forces the Polars engine.

Parameters

string
The SQL query to run. Pass a bare string as the only argument for the common case, or use the options object for anything else. Mutually exclusive with script.
string
A Polars DataFrame script that assigns result. Requires tables.
QueryTable[]
Tables the script reads, as { alias, table }.
"auto" | "duckdb" | "polars" | "bloom"
default:"\"auto\""
Ask for a specific engine. An impossible combination returns an engine capability error rather than rerouting.
boolean
default:"false"
Return the routing decision without executing.

querySubmit(options)

Covers everything that changes data: a SELECT plus a destination to write it to, and a statement that names its own target (INSERT, UPDATE, DELETE, MERGE, DDL) with no destination. It also takes reads too large to return interactively. Whether the write finishes on the call depends on the engine the router picked, so read state. Result rows are never returned, only row_count when it is known.

querySubmitAndWait(options)

Submits and polls until an asynchronous run finishes. A write that lands inline returns immediately with no run.

Parameters

string
The statement to run. With a destination, a SELECT; without one, a statement that names its own target.
string
Table to write the result to, as namespace.table.
"overwrite" | "append"
default:"\"overwrite\""
Applies to a destination write. A statement that names its own target carries its own semantics.
"auto" | "duckdb" | "polars" | "bloom" | "spark"
default:"\"auto\""
Ask for a specific engine.
boolean
default:"false"
Return the routing decision without submitting anything.

query(sql, options?)

query predates the router. It always runs DuckDB, sized by the org’s default sandbox setting rather than by the query. Prefer queryRun; reach for this only when you need save: true.
Executes SQL against the lake on DuckDB, with optional auto-save by query hash. If the API rejects the query, the SDK throws instead of returning a failed result.

Parameters

string
required
The SQL query to execute. Supports DuckDB SQL syntax.
boolean
default:"false"
When true, persists query results as a table. The table name is returned in saved_table_name.

Return fields

Iterating over results