Commit bc4571d
authored
[SEA-NodeJS] Sync execute via directResults (executeStatementDirect): fix CREATE, drop close-drives, keep cancel (#426)
* [SEA-NodeJS] Sync execute via directResults (executeStatementDirect)
The default sync path (`runAsync: false`) now calls the kernel's additive
`Connection.executeStatementDirect` instead of `executeStatementCancellable`.
The kernel runs ExecuteStatement with a bounded server inline wait and returns
WITHOUT polling past it; the session feature-detects the arm via `awaitResult`:
a fast query comes back as a terminal `Statement` (result inline) → wrapped with
the operation backend's `statement` arm; a slow one as an `AsyncStatement` →
the `asyncStatement` arm.
Because the returned handle always corresponds to a server-owned statement:
- fire-and-forget CREATE/INSERT commits (server runs it inline in the POST);
- `close()` is a clean release, never a drive-to-terminal (no close-drives);
- a long query stays cancellable via `op.cancel()` (~150-300ms), Thrift parity;
- errors surface at `executeStatement`, matching Thrift / Python use_kernel.
Requires the kernel's additive directResults execute
(databricks/databricks-sql-kernel#140). `execute()` on the kernel is unchanged,
so Python `use_kernel` needs no change. Regenerated napi types add
`executeStatementDirect`.
Validated e2e (pecotesting): CREATE fire-and-forget commits, 100k read, error
at execute, mid-run cancel, close() cheap (~120ms) on an abandoned long query.
Unit: SEA suite 260 passing; eslint clean.
Co-authored-by: Isaac
Signed-off-by: Madhavendra Rathore <madhavendra.rathore@databricks.com>
* [SEA-NodeJS] Address review: test the AsyncStatement arm; type-guard; null + stale comments
- F1: add coverage for the directResults Running (AsyncStatement) arm — the
branch the PR exists to add. Three tests via the fake's `directReturnsRunning`:
(a) a still-running query routes through the AsyncStatement arm and is driven
via `status()`/`waitUntilReady()`; (b) `op.cancel()` reaches the running
statement's `cancel()`; (c) contrast — a fast query routes through the terminal
`Statement` arm and cancel reaches it there. Previously `directReturnsRunning`
was never set, so the async arm had zero coverage.
- F4: replace the `as unknown as` double-casts with a cast-free user-defined type
guard `isSeaAsyncStatement` (the napi `Statement`/`AsyncStatement` are the exact
alias types, so no laundering is needed). Idiomatic, narrows both arms.
- F5: reject a null/undefined `direct` up front via `logAndMapError`
(HiveDriverError) instead of the inconsistent `direct !== null` guard that let a
null fall through to the `{statement}` arm and defer an opaque TypeError.
- F3: update the stale `runAsync` selector comment (still described
`executeStatementCancellable` + blocking `result()`) to directResults; fix the
stale `executeStatementCancellable` comment in the test.
- Document the `queryTimeout`→`wait_timeout=Ns`+CANCEL interaction (a timeout
shorter than the query cancels it rather than returning the Running handle).
SEA unit suite 263 passing (3 new); eslint clean.
Co-authored-by: Isaac
Signed-off-by: Madhavendra Rathore <madhavendra.rathore@databricks.com>
* [SEA-NodeJS] Regenerate napi .d.ts JSDoc to match corrected kernel direct-path docs
executeStatementDirect JSDoc now reflects: no wait_timeout field (server default
inline wait + auto-close), the awaitResult feature-detect contract, and the
queryTimeout->CANCEL interaction. Doc-only; no API surface change.
Co-authored-by: Isaac
Signed-off-by: Madhavendra Rathore <madhavendra.rathore@databricks.com>
* [SEA-NodeJS] Make queryTimeout a no-op on SEA (stop abusing wait_timeout)
`queryTimeout` was mapped to the kernel's `wait_timeout` (via `query_timeout_secs`
→ `wait_timeout={N}s` + CANCEL). That is semantically wrong: `wait_timeout` is the
server's inline-HOLD window (how long the POST blocks for results, capped 5–50s),
NOT a statement-execution timeout. Mapping queryTimeout there silently caps it at
50s, rejects <5s with HTTP 400, and conflates the inline wait with execution.
Per the option's own JSDoc, `queryTimeout` is "effective only with Compute
clusters; for SQL Warehouses use the STATEMENT_TIMEOUT configuration" — and SEA
targets SQL Warehouses. So make it a clean no-op on the SEA backend: not forwarded
to the kernel (sync directResults path no longer sends `query_timeout_secs`), and
not applied as a client-side deadline (async path). Drop the now-dead
`buildExecuteOptions` param and the unused `numberToInt64` import.
Verified e2e: `queryTimeout: 5` on a ~35s query previously cancelled at ~5s; it now
runs to completion (no-op). directResults CREATE/close/cancel unaffected.
Tests: sync + async paths now assert queryTimeout is NOT forwarded; removed the
obsolete Int64 client-side-deadline test. SEA suite 262 passing; eslint clean.
Co-authored-by: Isaac
Signed-off-by: Madhavendra Rathore <madhavendra.rathore@databricks.com>
* [SEA-NodeJS] Remove the dead queryTimeout deadline plumbing (kernel field gone)
Follow-on to making queryTimeout a no-op on SEA: now that the kernel's
`query_timeout_secs` field is removed (databricks/databricks-sql-kernel#140) and
SeaSessionBackend no longer passes a timeout, the SeaOperationBackend client-side
deadline is dead code. Remove it:
- `SeaOperationBackend`: drop the `queryTimeoutSecs` option, the `queryTimeoutMs`
field, and the async poll-loop deadline enforcement (the
`OperationStateError(Timeout)` + best-effort-cancel branch).
- Regenerated napi `.d.ts`: `ExecuteOptions` no longer carries `queryTimeoutSecs`.
- Tests: remove the obsolete client-side-deadline test; drop the `queryTimeoutSecs`
args from the `makeAsyncOp` / `makeSyncOp` helpers.
- Comment cleanups in SeaNativeLoader.
queryTimeout remains a no-op on SEA (SQL Warehouses use STATEMENT_TIMEOUT). SEA
unit suite 261 passing; eslint clean; e2e directResults (CREATE/close/cancel)
unaffected.
Co-authored-by: Isaac
Signed-off-by: Madhavendra Rathore <madhavendra.rathore@databricks.com>
* style: prettier-format SeaOperationBackend + execution.test after queryTimeout removal
CI runs `prettier . --check` (not just eslint); the deadline-plumbing removal left
two files needing a prettier reflow.
Co-authored-by: Isaac
Signed-off-by: Madhavendra Rathore <madhavendra.rathore@databricks.com>
---------
Signed-off-by: Madhavendra Rathore <madhavendra.rathore@databricks.com>1 parent f4d1675 commit bc4571d
5 files changed
Lines changed: 184 additions & 192 deletions
File tree
- lib/sea
- native/sea
- tests/unit/sea
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
56 | 56 | | |
57 | 57 | | |
58 | 58 | | |
59 | | - | |
| 59 | + | |
60 | 60 | | |
61 | 61 | | |
62 | 62 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
140 | 140 | | |
141 | 141 | | |
142 | 142 | | |
143 | | - | |
144 | | - | |
145 | | - | |
146 | | - | |
147 | | - | |
148 | | - | |
149 | | - | |
150 | | - | |
151 | | - | |
152 | 143 | | |
153 | 144 | | |
154 | 145 | | |
| |||
190 | 181 | | |
191 | 182 | | |
192 | 183 | | |
193 | | - | |
194 | | - | |
195 | | - | |
196 | | - | |
197 | | - | |
198 | | - | |
199 | | - | |
200 | | - | |
201 | | - | |
202 | | - | |
203 | | - | |
204 | | - | |
| 184 | + | |
205 | 185 | | |
206 | 186 | | |
207 | 187 | | |
| |||
232 | 212 | | |
233 | 213 | | |
234 | 214 | | |
235 | | - | |
236 | 215 | | |
237 | 216 | | |
238 | 217 | | |
| |||
441 | 420 | | |
442 | 421 | | |
443 | 422 | | |
444 | | - | |
445 | | - | |
446 | | - | |
447 | 423 | | |
448 | 424 | | |
449 | 425 | | |
| |||
494 | 470 | | |
495 | 471 | | |
496 | 472 | | |
497 | | - | |
498 | | - | |
499 | | - | |
500 | | - | |
501 | | - | |
502 | | - | |
503 | | - | |
504 | | - | |
505 | | - | |
506 | | - | |
507 | | - | |
508 | | - | |
509 | | - | |
510 | | - | |
511 | | - | |
512 | | - | |
513 | | - | |
514 | | - | |
515 | | - | |
516 | | - | |
517 | | - | |
518 | | - | |
519 | | - | |
520 | | - | |
| 473 | + | |
| 474 | + | |
521 | 475 | | |
522 | 476 | | |
523 | 477 | | |
| |||
526 | 480 | | |
527 | 481 | | |
528 | 482 | | |
529 | | - | |
| 483 | + | |
530 | 484 | | |
531 | 485 | | |
532 | 486 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
33 | 33 | | |
34 | 34 | | |
35 | 35 | | |
36 | | - | |
| 36 | + | |
37 | 37 | | |
38 | | - | |
39 | 38 | | |
40 | 39 | | |
41 | 40 | | |
| |||
67 | 66 | | |
68 | 67 | | |
69 | 68 | | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
70 | 82 | | |
71 | 83 | | |
72 | 84 | | |
| |||
122 | 134 | | |
123 | 135 | | |
124 | 136 | | |
125 | | - | |
126 | | - | |
127 | | - | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
128 | 140 | | |
129 | 141 | | |
130 | 142 | | |
| |||
164 | 176 | | |
165 | 177 | | |
166 | 178 | | |
167 | | - | |
168 | | - | |
169 | | - | |
170 | | - | |
171 | | - | |
172 | | - | |
173 | | - | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
174 | 187 | | |
175 | 188 | | |
176 | 189 | | |
177 | 190 | | |
178 | | - | |
179 | | - | |
180 | | - | |
| 191 | + | |
| 192 | + | |
181 | 193 | | |
182 | | - | |
183 | | - | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
184 | 204 | | |
185 | 205 | | |
186 | | - | |
187 | | - | |
188 | | - | |
189 | | - | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
190 | 217 | | |
191 | | - | |
| 218 | + | |
192 | 219 | | |
193 | | - | |
194 | | - | |
| 220 | + | |
| 221 | + | |
195 | 222 | | |
196 | 223 | | |
197 | 224 | | |
198 | | - | |
199 | | - | |
200 | | - | |
201 | | - | |
202 | | - | |
203 | | - | |
204 | | - | |
205 | | - | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
206 | 241 | | |
207 | 242 | | |
208 | | - | |
209 | | - | |
| 243 | + | |
| 244 | + | |
210 | 245 | | |
211 | 246 | | |
212 | 247 | | |
| |||
217 | 252 | | |
218 | 253 | | |
219 | 254 | | |
220 | | - | |
221 | | - | |
222 | | - | |
223 | | - | |
| 255 | + | |
| 256 | + | |
224 | 257 | | |
225 | 258 | | |
226 | 259 | | |
227 | | - | |
228 | | - | |
229 | | - | |
230 | 260 | | |
231 | 261 | | |
232 | 262 | | |
| |||
235 | 265 | | |
236 | 266 | | |
237 | 267 | | |
238 | | - | |
239 | | - | |
240 | | - | |
241 | | - | |
| 268 | + | |
242 | 269 | | |
243 | 270 | | |
244 | 271 | | |
| |||
256 | 283 | | |
257 | 284 | | |
258 | 285 | | |
259 | | - | |
260 | | - | |
261 | | - | |
262 | | - | |
263 | | - | |
264 | | - | |
265 | | - | |
266 | | - | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
267 | 289 | | |
268 | 290 | | |
269 | 291 | | |
| |||
0 commit comments