Skip to content

feat(kernel): consume the folded directResults execute()#837

Closed
msrathore-db wants to merge 1 commit into
mainfrom
msrathore/use-kernel-directresults
Closed

feat(kernel): consume the folded directResults execute()#837
msrathore-db wants to merge 1 commit into
mainfrom
msrathore/use-kernel-directresults

Conversation

@msrathore-db
Copy link
Copy Markdown
Contributor

@msrathore-db msrathore-db commented Jun 6, 2026

What

Adapt KernelDatabricksClient.execute_command to the kernel's folded directResults execute() (databricks/databricks-sql-kernel#136), which now returns a single ExecutedAsyncStatement — seeded with the inline result when the query finished within the server inline wait (fast path, zero extra round-trips), or a poll/cancel handle when still running — instead of always blocking to terminal.

The sync path now drives one uniform flow (no hasattr(await_result) arm to feature-detect): register the handle (so cursor.cancel() / close() reach it), then await_result() to drive it to a ready result set — preserving execute()'s blocking contract.

Caller-visible behaviour

cursor.execute() is unchanged for callers (still blocks to a ready result set); this just adapts to the kernel's new single-handle return. Mid-run cancel still works via the _sync_cancellers canceller registered before execute.

Testing

Tested e2e against live warehouses (auto-closing and non-auto-closing): SELECT 1, range(N), and CREATE+count all succeed on both. The kernel maps an auto-closed CLOSED statement to Succeeded, so the connector sees a uniform success regardless of warehouse auto-close behaviour.

This pull request and its description were written by Isaac.

The kernel's `Statement.execute()` is now the directResults call
(databricks/databricks-sql-kernel#136): it returns a SINGLE
`ExecutedAsyncStatement` -- seeded with the inline result when the query finished
within the server inline wait (fast path, zero extra round-trips), or a
poll/cancel handle when still running -- instead of always blocking to terminal.

`KernelDatabricksClient.execute_command` now drives ONE uniform path (no
`hasattr(await_result)` arm to feature-detect): register the handle (so
`cursor.cancel()` / `close()` reach it), then `await_result()` to drive it to a
ready result set -- preserving execute()'s blocking contract.

`cursor.execute()` behaviour is unchanged for callers (still blocks to a ready
result set); this just adapts to the kernel's new single-handle return. Mid-run
cancel still works via the `_sync_cancellers` canceller registered before
execute.

Tested e2e against live warehouses (auto-closing and non-auto-closing): SELECT 1,
range(N), and CREATE+count all succeed on both. The kernel maps an auto-closed
`CLOSED` statement to `Succeeded`, so the connector sees a uniform success
regardless of warehouse auto-close behaviour.

Co-authored-by: Isaac
Signed-off-by: Madhavendra Rathore <madhavendra.rathore@databricks.com>
@msrathore-db msrathore-db force-pushed the msrathore/use-kernel-directresults branch from acecd76 to 8974e7b Compare June 6, 2026 14:20
@msrathore-db msrathore-db deployed to azure-prod June 6, 2026 14:20 — with GitHub Actions Active
@msrathore-db
Copy link
Copy Markdown
Contributor Author

Not needed with the additive kernel approach (databricks/databricks-sql-kernel#140). That PR adds execute_direct() alongside an unchanged blocking execute(), so use_kernel keeps using execute() exactly as today — no client.py change. Verified e2e against the additive kernel on the unchanged upstream/main driver: CREATE commits, close() cheap (no close-drive), mid-run cancel works (258ms, via the existing _sync_cancellers canceller). The await_result adaptation here was only required for the in-place fold (kernel #136, closed).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant