Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

[SEA-NodeJS] Sync execute via directResults: fix CREATE, drop close-drives, keep mid-run cancel#425

Closed
msrathore-db wants to merge 1 commit into
maindatabricks/databricks-sql-nodejs:mainfrom
msrathore/sea-directresults-pocdatabricks/databricks-sql-nodejs:msrathore/sea-directresults-pocCopy head branch name to clipboard
Closed

[SEA-NodeJS] Sync execute via directResults: fix CREATE, drop close-drives, keep mid-run cancel#425
msrathore-db wants to merge 1 commit into
maindatabricks/databricks-sql-nodejs:mainfrom
msrathore/sea-directresults-pocdatabricks/databricks-sql-nodejs:msrathore/sea-directresults-pocCopy head branch name to clipboard

Conversation

@msrathore-db
Copy link
Copy Markdown
Contributor

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

What

The default sync (runAsync: false) path now calls the kernel's folded directResults execute() (Connection.executeStatement), which returns a single AsyncStatement handle. The session wraps it with the operation backend's existing asyncStatement arm — no arm to feature-detect.

Why this fixes the SEA gaps

The returned handle always corresponds to a server-owned statement:

  • fire-and-forget CREATE/INSERT commits — the server runs it inline during the POST. Fixes the prior lazy-execute "CREATE didn't run" bug.
  • close() is a clean release, never a drive-to-terminal — the eager-handle + close-drives workaround is gone.
  • mid-run cancel via op.cancel() (asyncStatement.cancel()) once the handle is held (~80–300ms), at parity with the Thrift backend.
  • errors surface at executeStatement, matching Thrift / Python use_kernel.

On the fast path the kernel handle is seeded with the inline result, so the first fetch/status is served with zero extra round-trips (and is 404-proof — a terminal handle never polls a released statement). On a warehouse that auto-closes the statement (state=CLOSED) after delivering its inline result, the kernel maps CLOSED → Succeeded, so this path no longer throws OperationStateError(Closed).

This replaces the earlier enum approach (executeStatement returning a terminal Statement or an AsyncStatement, feature-detected via awaitResult) — one uniform handle.

Dependency

Requires the kernel folded directResults execute(): databricks/databricks-sql-kernel#136. Regenerated napi router types (executeStatement now returns AsyncStatement); fallback package names stay on the driver's canonical @databricks/sql-kernel-*.

Testing

Validated e2e (pecotesting) against auto-closing AND non-auto-closing warehouses: CREATE fire-and-forget commits (12/12 = Thrift parity), fetch-then-close (12/12), mid-run cancel, close() cheap (~140ms) on an abandoned long query, SELECT 1 p50 179ms vs Thrift 168ms. Unit: SEA suite 247 passing; eslint clean.

This pull request and its description were written by Isaac.

…rives, keep mid-run cancel

The default sync path now calls the kernel's folded directResults `execute()`
(`Connection.executeStatement`), which returns a SINGLE `AsyncStatement` handle.
The session wraps it with the operation backend's existing `asyncStatement` arm —
no arm to feature-detect.

The returned handle always corresponds to a server-owned statement:
  - fire-and-forget `CREATE`/`INSERT` commits (the server runs it inline during
    the POST) — fixes the prior lazy-execute "CREATE didn't run" bug;
  - `close()` is a clean release, never a drive-to-terminal — the eager-handle +
    close-drives workaround is gone;
  - a long query is cancellable via `op.cancel()` (`asyncStatement.cancel()`)
    once the handle is held (~80-300ms), at parity with the Thrift backend;
  - errors surface at `executeStatement`, matching Thrift / Python use_kernel.

On the fast path the kernel handle is seeded with the inline result, so the
first fetch/status is served with zero extra round-trips (and is 404-proof — a
terminal handle never polls a released statement). A warehouse that auto-closes
the statement (`state=CLOSED`) after delivering its inline result is handled by
the kernel mapping `CLOSED -> Succeeded`, so this path no longer throws
`OperationStateError(Closed)` on those warehouses.

Requires the kernel folded directResults execute
(databricks/databricks-sql-kernel#136). Regenerated napi router types
(`executeStatement` now returns `AsyncStatement`); fallback package names stay on
the driver's canonical `@databricks/sql-kernel-*`.

Validated e2e (pecotesting) against auto-closing AND non-auto-closing warehouses:
CREATE fire-and-forget commits (12/12 = Thrift parity), fetch-then-close (12/12),
mid-run cancel, close() cheap (~140ms) on an abandoned long query, SELECT 1 p50
179ms vs Thrift 168ms. Unit: SEA suite 247 passing; eslint clean.

Co-authored-by: Isaac
Signed-off-by: Madhavendra Rathore <madhavendra.rathore@databricks.com>
@msrathore-db msrathore-db force-pushed the msrathore/sea-directresults-poc branch from 8bffb1e to 81bd16d Compare June 6, 2026 14:19
@msrathore-db
Copy link
Copy Markdown
Contributor Author

Superseded by the additive approach: kernel #140 adds execute_direct alongside an unchanged execute(), and this driver consumes executeStatementDirect. New PR supersedes this one.

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

Morty Proxy This is a proxified and sanitized view of the page, visit original site.