Skip to main content

polars(options)

Run a Polars SQL query or a Python script over lake tables. Provide exactly one of query or script. If the API rejects the run, the SDK raises instead of returning a failed result.

Query mode

Query mode requires at least one table binding, either as "namespace.table" (the alias defaults to the table name) or as PolarsTable(alias=..., table=...).

Script mode

Pass a Python script that uses Polars. Use params to inject values, and destination/save_mode to persist the result as a lake table.

Distributed runs

Pass distributed=True with a destination to run on Polars Cloud.

Parameters

options.query
str
Polars SQL query. Provide exactly one of query or script.
options.script
str
Python script source using Polars. Provide exactly one of query or script.
options.tables
list[str | PolarsTable]
default:"[]"
Table bindings. Required (at least one) in query mode.
options.params
dict[str, Any]
default:"{}"
Parameters made available to the script.
options.distributed
bool
default:"False"
Run on Polars Cloud. Requires destination.
options.catalog
str
Catalog to resolve tables against.
options.instance_type
str
Instance type for distributed runs.
options.cluster_size
int
Cluster size for distributed runs, from 1 to 64.
options.vcpus
int
vCPUs per instance, from 1 to 32.
options.destination
str
Lake table to write results to. Required when distributed=True.
options.save_mode
str
default:"overwrite"
overwrite or append. Applies when writing to destination.
Polars runs execute compute synchronously and can take minutes when a sandbox cold-starts or a distributed cluster spins up. The SDK uses an extended request timeout of 30 minutes for Polars runs.

Return type: PolarsResult

FieldTypeDescription
successboolWhether the run executed successfully
resultsOptional[QueryResultColumns]Results with columns, column_types, and rows
row_countOptional[int]Number of rows returned
execution_timeOptional[str]Run execution time
savedOptional[PolarsSaved]table, rows_written, and mode when results were persisted
computeOptional[PolarsCompute]mode, distributed, instance_type, cluster_size