Commit a9347e8
committed
sea-abstraction: address PR #378 review-comment fixes (H1 / M1-M4 / L1-L10)
Addresses 15 review findings from the code-review-squad pass on PR #378.
L11 (backend kind field on the three interfaces) is deliberately deferred
to avoid a cross-stack cascade ripple while the downstream PRs are still
in flight.
H1 — fetchChunk lost mid-flight failIfClosed regression.
Add optional `isClosed?: () => boolean` to IOperationBackend.fetchChunk's
options bag. ThriftOperationBackend.fetchChunk probes it after the
setTimeout(0) macrotask yield and returns [] when set; the facade's
post-fetch failIfClosed then raises the user-visible OperationStateError.
Restores the guard that the refactor split across the facade/backend
boundary so a cancel/close arriving during the yield window no longer
runs the data RPC to completion needlessly.
M1 — neutralize WaitUntilReadyOptions callback shape.
Introduce IOperationBackendWaitOptions { callback?: (status:
OperationStatus) => unknown } on the backend interface. Facade keeps
the public Thrift-typed OperationStatusCallback and adapts at the
boundary by wrapping the user's callback with synthesizeThriftStatus.
ThriftOperationBackend.waitUntilReady consumes the neutral options and
passes adaptOperationStatus(response) to the callback.
M2 — synthesizeOkStatus maps OperationState to TStatusCode.
Add synthesizeStatusFromOperation that returns ERROR_STATUS for
Failed/Cancelled/Closed (carrying errorMessage + sqlState) and
SUCCESS_STATUS otherwise. Wire it into synthesizeThriftStatus so
legacy Status.assert(resp.status) sees the right code on non-Thrift
backends.
M3 — TelemetryEvent + DriverConfiguration carry a backend tag.
Add optional backend?: 'thrift' | 'sea' | 'kernel' on both interfaces
so dashboards can slice latency/error rate by backend without a
metrics-schema migration once non-Thrift emission goes live.
M4 — test coverage for the synthesize helpers + useSEA failure path.
New tests/unit/thrift-backend/wireSynthesis.test.ts covering all
OperationState/ResultFormat mappings, ERROR_STATUS carries
errorMessage/sqlState, hasResultSet round-trip, schema/arrowSchema/
lz4Compressed/isStagingOperation preservation, and the L3 throw on
unknown ResultFormat. New test in DBSQLClient.test.ts asserts that a
useSEA:true connect failure leaves this.backend === undefined and the
next openSession() surfaces "not connected" rather than the
SeaBackend's "not implemented" error.
L1 — forwardConnectionEvent normalizes payload to Error.
Replace `payload as Error` with `payload instanceof Error ? payload
: new Error(String(payload))` so a backend that emits a non-Error
through the cross-backend onConnectionEvent doesn't crash the
logger.log call.
L2 — DBSQLClient.connect publishes this.backend only on success.
Construct the backend locally, await connect() in a try/catch, run a
best-effort backend.close() (per IBackend.close()'s
safe-on-partial-init contract) and rethrow on failure. Only assign
this.backend after a clean connect so a failed connect surfaces
"DBSQLClient: not connected" on the next openSession.
L3 — resultFormatToThrift throws on unknown ResultFormat.
Replace the silent default fallback to COLUMN_BASED_SET with a
HiveDriverError. Prevents a future ResultFormat enum extension from
silently routing results through JsonResultHandler and surfacing
garbled rows.
L4 — DBSQLOperation.getMetadata carries @deprecated.
Adds the canonical TypeScript JSDoc tag so IDEs (strikethrough), tsc,
ESLint plugins, and agentic codegen pick up the soft deprecation in
favour of getResultMetadata.
L5 — numberToInt64 re-export carries @deprecated.
Re-export through a named const with a JSDoc block (rather than a
bare `export { ... } from`) so the @deprecated tag attaches to the
symbol consumers see in their IDE / .d.ts.
L6 — DBSQLSession.runBackend helper.
Collapse 11 duplicated `failIfClosed → backend.X → failIfClosed`
brackets into a single private runBackend<T>(fn) so the
open-flag-before-and-after contract has a name and can't be forgotten
in a new delegation method.
L7 — restore three why-comments deleted from DBSQLSession.
Staging-detection invariant in executeStatement, AWS-vs-Azure 404
difference on staging-remove, and the Content-Length-required note on
staging-upload. Verbatim from main; these document non-obvious
intentional behaviour the refactor inadvertently dropped.
L8 — hasResultSet becomes a method on IOperationBackend.
The value is state-dependent (the Thrift impl mutates the underlying
operation handle inside processOperationStatusResponse), so the
property+readonly+disclaimer-JSDoc pattern was misleading. Method
form makes the live-read semantics obvious to a fresh implementer.
3 facade call sites updated.
L9 — wireSynthesis moves under thrift-backend.
The file imports Thrift IDL types and produces Thrift-typed values;
it belongs next to ThriftOperationBackend, not in the neutral
lib/utils/ tree where it would creep into the dependency cone of
future backend-neutral helpers. Same reasoning that placed
numberToInt64 and getDirectResultsOptions under thrift-backend/.
L10 — interface-level downcast policy.
Add a JSDoc paragraph on IOperationBackend grandfathering the two
existing `instanceof ThriftOperationBackend` downcasts in
DBSQLOperation.status/getMetadata and prohibiting new ones. Future
zero-loss back-compat needs should extend the interface (or add an
optional method) rather than spawn a per-backend branch matrix.
Gates: yarn build (exit 0), yarn lint (0 errors, 3 pre-existing
warnings in tests/e2e/protocol_versions.test.ts), yarn test on touched
files (163 passing, +12 net new tests from M4 work; 2 failures pre-
existing on PR head unchanged: getSchema-directResults and the
LZ4-cloud-fetch flag — both flagged in the team-lead playbook as
known prior regressions).
Cascade implications for downstream PRs (#380 #377 #379 #382 #381
#384 #383): L8 converts hasResultSet from a property to a method,
M1 swaps WaitUntilReadyOptions for IOperationBackendWaitOptions on
the backend interface. Both are mechanical renames at downstream
backend impls when they rebase.
Co-authored-by: Isaac
Signed-off-by: Madhavendra Rathore <madhavendra.rathore@databricks.com>1 parent 8a22d54 commit a9347e8
9 files changed
Lines changed: 378 additions & 78 deletions
File tree
- lib
- contracts
- telemetry
- thrift-backend
- tests/unit
- thrift-backend
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
242 | 242 | | |
243 | 243 | | |
244 | 244 | | |
245 | | - | |
| 245 | + | |
246 | 246 | | |
247 | 247 | | |
248 | 248 | | |
249 | 249 | | |
250 | 250 | | |
251 | 251 | | |
252 | | - | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
253 | 270 | | |
254 | 271 | | |
255 | 272 | | |
256 | 273 | | |
257 | 274 | | |
258 | 275 | | |
259 | 276 | | |
260 | | - | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
261 | 282 | | |
262 | 283 | | |
263 | 284 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
22 | | - | |
| 22 | + | |
23 | 23 | | |
24 | 24 | | |
25 | | - | |
| 25 | + | |
26 | 26 | | |
27 | 27 | | |
28 | 28 | | |
| |||
114 | 114 | | |
115 | 115 | | |
116 | 116 | | |
117 | | - | |
| 117 | + | |
118 | 118 | | |
119 | 119 | | |
120 | 120 | | |
| |||
123 | 123 | | |
124 | 124 | | |
125 | 125 | | |
126 | | - | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
127 | 131 | | |
128 | 132 | | |
129 | 133 | | |
| |||
192 | 196 | | |
193 | 197 | | |
194 | 198 | | |
195 | | - | |
| 199 | + | |
196 | 200 | | |
197 | 201 | | |
198 | 202 | | |
| |||
202 | 206 | | |
203 | 207 | | |
204 | 208 | | |
205 | | - | |
| 209 | + | |
206 | 210 | | |
207 | 211 | | |
208 | 212 | | |
| |||
227 | 231 | | |
228 | 232 | | |
229 | 233 | | |
230 | | - | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
231 | 237 | | |
232 | 238 | | |
233 | 239 | | |
| |||
248 | 254 | | |
249 | 255 | | |
250 | 256 | | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
251 | 270 | | |
252 | | - | |
| 271 | + | |
253 | 272 | | |
254 | 273 | | |
255 | 274 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
26 | 26 | | |
27 | 27 | | |
28 | 28 | | |
| 29 | + | |
29 | 30 | | |
30 | 31 | | |
31 | 32 | | |
32 | 33 | | |
33 | | - | |
34 | | - | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
35 | 43 | | |
36 | 44 | | |
37 | 45 | | |
| |||
68 | 76 | | |
69 | 77 | | |
70 | 78 | | |
71 | | - | |
72 | | - | |
73 | | - | |
74 | | - | |
| 79 | + | |
75 | 80 | | |
76 | 81 | | |
77 | 82 | | |
| |||
84 | 89 | | |
85 | 90 | | |
86 | 91 | | |
87 | | - | |
88 | | - | |
89 | | - | |
| 92 | + | |
90 | 93 | | |
91 | 94 | | |
92 | | - | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
93 | 102 | | |
94 | 103 | | |
95 | 104 | | |
| |||
174 | 183 | | |
175 | 184 | | |
176 | 185 | | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
177 | 193 | | |
178 | 194 | | |
179 | 195 | | |
| |||
198 | 214 | | |
199 | 215 | | |
200 | 216 | | |
| 217 | + | |
201 | 218 | | |
202 | 219 | | |
203 | 220 | | |
| |||
215 | 232 | | |
216 | 233 | | |
217 | 234 | | |
218 | | - | |
219 | | - | |
220 | | - | |
221 | | - | |
| 235 | + | |
222 | 236 | | |
223 | 237 | | |
224 | 238 | | |
| |||
228 | 242 | | |
229 | 243 | | |
230 | 244 | | |
231 | | - | |
232 | | - | |
233 | | - | |
234 | | - | |
| 245 | + | |
235 | 246 | | |
236 | 247 | | |
237 | 248 | | |
| |||
241 | 252 | | |
242 | 253 | | |
243 | 254 | | |
244 | | - | |
245 | | - | |
246 | | - | |
247 | | - | |
| 255 | + | |
248 | 256 | | |
249 | 257 | | |
250 | 258 | | |
| |||
254 | 262 | | |
255 | 263 | | |
256 | 264 | | |
257 | | - | |
258 | | - | |
259 | | - | |
260 | | - | |
| 265 | + | |
261 | 266 | | |
262 | 267 | | |
263 | 268 | | |
| |||
267 | 272 | | |
268 | 273 | | |
269 | 274 | | |
270 | | - | |
271 | | - | |
272 | | - | |
273 | | - | |
| 275 | + | |
274 | 276 | | |
275 | 277 | | |
276 | 278 | | |
| |||
280 | 282 | | |
281 | 283 | | |
282 | 284 | | |
283 | | - | |
284 | | - | |
285 | | - | |
286 | | - | |
| 285 | + | |
287 | 286 | | |
288 | 287 | | |
289 | 288 | | |
| |||
293 | 292 | | |
294 | 293 | | |
295 | 294 | | |
296 | | - | |
297 | | - | |
298 | | - | |
299 | | - | |
| 295 | + | |
300 | 296 | | |
301 | 297 | | |
302 | 298 | | |
303 | | - | |
304 | | - | |
305 | | - | |
306 | | - | |
| 299 | + | |
307 | 300 | | |
308 | 301 | | |
309 | 302 | | |
| |||
313 | 306 | | |
314 | 307 | | |
315 | 308 | | |
316 | | - | |
317 | | - | |
318 | | - | |
319 | | - | |
| 309 | + | |
320 | 310 | | |
321 | 311 | | |
322 | 312 | | |
| |||
346 | 336 | | |
347 | 337 | | |
348 | 338 | | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
349 | 354 | | |
350 | 355 | | |
351 | 356 | | |
| |||
0 commit comments