[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#425msrathore-db wants to merge 1 commit intomaindatabricks/databricks-sql-nodejs:mainfrom msrathore/sea-directresults-pocdatabricks/databricks-sql-nodejs:msrathore/sea-directresults-pocCopy head branch name to clipboard
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
63a8761 to
8bffb1e
Compare
…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>
8bffb1e to
81bd16d
Compare
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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
The default sync (
runAsync: false) path now calls the kernel's folded directResultsexecute()(Connection.executeStatement), which returns a singleAsyncStatementhandle. The session wraps it with the operation backend's existingasyncStatementarm — no arm to feature-detect.Why this fixes the SEA gaps
The returned handle always corresponds to a server-owned statement:
CREATE/INSERTcommits — 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.op.cancel()(asyncStatement.cancel()) once the handle is held (~80–300ms), at parity with the Thrift backend.executeStatement, matching Thrift / Pythonuse_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 mapsCLOSED → Succeeded, so this path no longer throwsOperationStateError(Closed).This replaces the earlier enum approach (
executeStatementreturning a terminalStatementor anAsyncStatement, feature-detected viaawaitResult) — one uniform handle.Dependency
Requires the kernel folded directResults
execute(): databricks/databricks-sql-kernel#136. Regenerated napi router types (executeStatementnow returnsAsyncStatement); 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 1p50 179ms vs Thrift 168ms. Unit: SEA suite 247 passing; eslint clean.This pull request and its description were written by Isaac.