DirectQuery#

class polars_cloud.DirectQuery(
query_id: UUID,
client: pcr.SchedulerClient,
cluster: ComputeContext | ClientContext,
)

A Polars Cloud direct connect query.

Note

This object is returned when spawning a new query on a compute cluster running in direct connect mode. It should not be instantiated directly by the user.

Examples

>>> ctx = pc.ComputeContext(connection_mode="direct")
>>> query = lf.remote(ctx).sink_parquet(...)
>>> type(query)
<class 'polars_cloud.query.query.DirectQuery'>

Methods:

get_status

Get the current status of the query.

get_profile

Get the current profile of the query if available.

await_result_async

Await the result of the query asynchronously and return the result.

await_result

Block the current thread until the query is processed and get a result.

await_profile_async

Wait for an update to the query profile asynchronously.

await_profile

Block the thread and wait until the query profile is updated.

cancel

Cancel the execution of the query.

graph

Return the query plan as dot diagram.

plan

Return the executed plan in string format.

get_status() QueryStatus

Get the current status of the query.

get_profile() QueryProfile | None

Get the current profile of the query if available.

async await_result_async(
*,
raise_on_failure: bool = True,
) QueryResult

Await the result of the query asynchronously and return the result.

await_result(
*,
raise_on_failure: bool = True,
) QueryResult

Block the current thread until the query is processed and get a result.

async await_profile_async() QueryProfile

Wait for an update to the query profile asynchronously.

await_profile() QueryProfile

Block the thread and wait until the query profile is updated.

cancel() None

Cancel the execution of the query.

graph(
plan_type: PlanType = 'physical',
*,
show: bool = True,
output_path: str | Path | None = None,
raw_output: bool = False,
figsize: tuple[float, float] = (16.0, 12.0),
) str | None

Return the query plan as dot diagram.

Parameters:
plan_type: {‘physical’, ‘ir’}

Plan visualization to return.

  • physical: The executed physical plan/stages.

  • ir: The optimized query plan before execution.

show

Show the figure.

output_path

Write the figure to disk.

raw_output

Return dot syntax. This cannot be combined with show and/or output_path.

figsize

Passed to matplotlib if show == True.

plan(plan_type: PlanType = 'physical') str

Return the executed plan in string format.

Parameters:
plan_type: {‘physical’, ‘ir’}

Plan visualization to return.

  • physical: The executed physical plan/stages.

  • ir: The optimized query plan before execution.