Repository navigation
Commit b307fb4
authored
[PECOBLR-2096] C ABI follow-up: lazy metadata streaming, empty-filter semantics, session-close delete initiation (#160)
Follow-up to #158 (merged), addressing @gopalldb's three post-merge
review findings on the v0 C ABI.
## [MAJOR] Unbounded metadata buffering → lazy streaming
`drain_metadata` materialized the whole metadata result into a
`Vec<RecordBatch>` at construction, justified as "bounded — a handful of
batches". That's false for `kernel_metadata_list_columns` with a NULL
catalog, which becomes `SHOW COLUMNS IN ALL CATALOGS` — a row per column
of every table in every visible catalog. In a large workspace an ODBC
`getColumns(null, …)` would materialize the entire cross-catalog column
inventory at once.
The owned result-stream handle now **holds the `ResultStream` and drives
`next_batch` lazily on the runtime** (one batch per
`kernel_result_stream_next_batch`, via `block_on_ffi` — the same
on-runtime discipline the executed path already uses to avoid driving a
CloudFetch reader off a plain C thread). `run_metadata` now captures
just the schema up front and hands the stream to the handle. Bounded
memory, no behavior change for consumers.
## [MAJOR] Empty-string identifier rejected instead of "unfiltered"
`opt_ident` mapped only a NULL pointer to `None`; a non-null empty
string became `Some("")` → `Identifier::new("")` → `InvalidArgument`.
ODBC/JDBC drivers commonly pass `""` (not NULL) to mean "match all", so
`list_schemas` / `list_tables` / `list_columns` rejected a legitimate
call. New `opt_filter_str` treats NULL and empty/whitespace-only alike
as `None`; `opt_ident` / `opt_pattern` route through it. Required
identifiers (PK/FK table) still correctly reject empty.
## [MAJOR] `kernel_session_close` didn't initiate DeleteSession when
handles outlive the session
Close dropped one `Arc<SessionInner>`; `DeleteSession` only fires from
`SessionInner::Drop` (last-Arc-drop). A live statement/executed handle
holds its own clone, so the delete was deferred until those were
released too — contradicting the header's "close initiates the delete"
contract and risking the server session lingering to idle-timeout. Added
`SessionInner::initiate_delete` (idempotent via a compare-and-swap on
`closed`; `Drop` now delegates to it), exposed
`Session::initiate_delete`, and call it from `kernel_session_close` so
the delete is initiated immediately regardless of outstanding handles.
## Docs + tests
- `databricks_kernel.h` and the Rust docs updated to match (metadata
NULL/empty semantics; close-initiation contract).
- Metadata empty→unfiltered unit tests (`opt_filter_str`, `opt_ident`).
- New C-ABI wiremock test asserting close initiates `DELETE` with a
statement handle still open.
- The existing owned-stream exhaustion test now builds a lazy
`ResultStream` via `MockReader`.
`cargo fmt` / `clippy --all-targets` clean; **673 lib tests + all
integration suites + C smoke** pass.
The dependent ODBC PR databricks/databricks-odbc#101 will re-pin
`KERNEL_REPO_TAG` to this PR's merge commit once it lands.
This pull request and its description were written by Isaac.
---------
Signed-off-by: Vikrant Puppala <vikrant.puppala@databricks.com>1 parent 285a8eb commit b307fb4
6 files changed
Lines changed: 357 additions & 88 deletions
File tree
- include
- src
- c_abi
- tests
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
56 | 56 | | |
57 | 57 | | |
58 | 58 | | |
59 | | - | |
60 | | - | |
61 | | - | |
62 | | - | |
63 | | - | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
64 | 73 | | |
65 | 74 | | |
66 | 75 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
19 | | - | |
20 | | - | |
21 | | - | |
22 | | - | |
23 | | - | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
24 | 25 | | |
25 | 26 | | |
26 | 27 | | |
| |||
32 | 33 | | |
33 | 34 | | |
34 | 35 | | |
35 | | - | |
| 36 | + | |
36 | 37 | | |
37 | | - | |
38 | 38 | | |
39 | 39 | | |
40 | 40 | | |
| |||
61 | 61 | | |
62 | 62 | | |
63 | 63 | | |
64 | | - | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
65 | 80 | | |
66 | | - | |
| 81 | + | |
67 | 82 | | |
68 | 83 | | |
69 | 84 | | |
70 | 85 | | |
71 | 86 | | |
72 | | - | |
| 87 | + | |
73 | 88 | | |
74 | | - | |
| 89 | + | |
75 | 90 | | |
76 | 91 | | |
77 | 92 | | |
78 | 93 | | |
79 | 94 | | |
80 | | - | |
81 | | - | |
82 | | - | |
83 | | - | |
84 | | - | |
85 | | - | |
86 | | - | |
87 | | - | |
88 | | - | |
89 | | - | |
90 | | - | |
91 | | - | |
92 | | - | |
93 | | - | |
94 | | - | |
95 | | - | |
96 | | - | |
97 | | - | |
98 | | - | |
99 | | - | |
100 | | - | |
101 | | - | |
102 | | - | |
103 | | - | |
104 | | - | |
105 | | - | |
106 | | - | |
107 | | - | |
108 | | - | |
109 | | - | |
110 | 95 | | |
111 | 96 | | |
112 | 97 | | |
| |||
131 | 116 | | |
132 | 117 | | |
133 | 118 | | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
134 | 123 | | |
135 | 124 | | |
136 | | - | |
| 125 | + | |
| 126 | + | |
137 | 127 | | |
138 | 128 | | |
139 | | - | |
140 | | - | |
| 129 | + | |
| 130 | + | |
141 | 131 | | |
142 | 132 | | |
143 | 133 | | |
| |||
338 | 328 | | |
339 | 329 | | |
340 | 330 | | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
23 | 23 | | |
24 | 24 | | |
25 | 25 | | |
26 | | - | |
27 | | - | |
28 | | - | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
29 | 33 | | |
30 | 34 | | |
31 | 35 | | |
| |||
51 | 55 | | |
52 | 56 | | |
53 | 57 | | |
54 | | - | |
55 | | - | |
56 | | - | |
57 | | - | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
58 | 63 | | |
59 | 64 | | |
60 | | - | |
| 65 | + | |
61 | 66 | | |
62 | 67 | | |
63 | 68 | | |
| |||
70 | 75 | | |
71 | 76 | | |
72 | 77 | | |
73 | | - | |
74 | | - | |
75 | | - | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
76 | 82 | | |
77 | 83 | | |
78 | | - | |
| 84 | + | |
79 | 85 | | |
80 | | - | |
81 | | - | |
82 | | - | |
83 | | - | |
| 86 | + | |
| 87 | + | |
84 | 88 | | |
85 | 89 | | |
86 | 90 | | |
| |||
205 | 209 | | |
206 | 210 | | |
207 | 211 | | |
208 | | - | |
209 | | - | |
210 | | - | |
211 | | - | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
212 | 240 | | |
213 | 241 | | |
214 | 242 | | |
| |||
306 | 334 | | |
307 | 335 | | |
308 | 336 | | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
309 | 355 | | |
310 | 356 | | |
311 | 357 | | |
312 | 358 | | |
313 | 359 | | |
314 | 360 | | |
315 | 361 | | |
316 | | - | |
| 362 | + | |
317 | 363 | | |
318 | 364 | | |
319 | 365 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
522 | 522 | | |
523 | 523 | | |
524 | 524 | | |
525 | | - | |
526 | | - | |
| 525 | + | |
| 526 | + | |
| 527 | + | |
| 528 | + | |
| 529 | + | |
| 530 | + | |
| 531 | + | |
| 532 | + | |
| 533 | + | |
| 534 | + | |
| 535 | + | |
527 | 536 | | |
528 | 537 | | |
529 | 538 | | |
| |||
539 | 548 | | |
540 | 549 | | |
541 | 550 | | |
542 | | - | |
543 | | - | |
544 | | - | |
545 | | - | |
546 | | - | |
547 | | - | |
| 551 | + | |
| 552 | + | |
| 553 | + | |
| 554 | + | |
| 555 | + | |
| 556 | + | |
| 557 | + | |
| 558 | + | |
| 559 | + | |
| 560 | + | |
| 561 | + | |
| 562 | + | |
| 563 | + | |
548 | 564 | | |
549 | 565 | | |
550 | 566 | | |
| |||
0 commit comments