Commit 3358a61
authored
feat(kernel): session-level query tags + Thrift-parity OAuth scopes (configurable) (#430)
* feat(kernel): wire session-level query tags into KernelBackend.openSession
Ports the session-level query-tags wiring onto the post-#428 lib/kernel path
(originally lib/sea/SeaBackend, before the SEA→kernel rename). openSession
serializes request.queryTags into the reserved QUERY_TAGS session conf, which
the kernel allowlists (SESSION_CONF_ALLOWLIST) and forwards onto the SEA
CreateSession session_confs — mirroring ThriftBackend.openSession. queryTags
takes precedence over an explicit configuration.QUERY_TAGS.
Verified end-to-end against a live warehouse: the tag lands in
system.query.history.query_tags.
Co-authored-by: Isaac
Signed-off-by: Madhavendra Rathore <madhavendra.rathore@databricks.com>
* fix(kernel): request Thrift-parity OAuth scopes, configurable via oauthScopes
The kernel U2M flow passed no scopes, so it fell through to the kernel's bare
default (all-apis offline_access). The databricks-sql-connector OAuth app is
registered for `sql`, so U2M auth used the wrong scope set. Pass scopes
explicitly from the driver:
- U2M defaults to ['sql', 'offline_access'] (matches the Thrift driver's
defaultOAuthScopes), overriding the kernel's all-apis default.
- M2M defaults to ['all-apis'] (matches Thrift + the kernel's M2M default).
- Both overridable via a new `oauthScopes` connect option — closing the
configurability gap with pyo3, which already forwards `scopes` on M2M.
Driver-only change: the napi binding already forwards oauth_scopes and the
kernel's u2m.rs/m2m.rs feed them into the authorize/token request.
Co-authored-by: Isaac
Signed-off-by: Madhavendra Rathore <madhavendra.rathore@databricks.com>
* fix(kernel): no-op unsupported per-statement options instead of throwing
Per-statement options the kernel backend doesn't honour are now NO-OPs (logged
at warn), not HiveDriverErrors, so call sites written for the Thrift backend are
drop-in on the kernel path:
- useCloudFetch / useLZ4Compression — kernel-governed perf/format hints
- stagingAllowedLocalPath — staging not yet exposed on the kernel
Ignoring these can't change query results. Parameter binding (compound/BINARY)
is deliberately NOT no-op'd — a dropped param would silently change results, so
it still throws.
Co-authored-by: Isaac
Signed-off-by: Madhavendra Rathore <madhavendra.rathore@databricks.com>
* feat(kernel): route OAuth identically to Thrift (strict parity) + custom U2M client id
Make the kernel auth flow selector + client-id resolution byte-for-byte identical
to the Thrift driver (`DBSQLClient.createAuthProvider`):
- flow = `oauthClientSecret === undefined ? U2M : M2M` (strict undefined)
- clientId = `oauthClientId ?? defaultClientId` (`??` guards null/undefined only)
No blank/reserved normalization on the OAuth fields — a present-but-degenerate
value (`""` / `"undefined"` / whitespace) is forwarded verbatim, exactly as Thrift
forwards it. This removes every divergence from the Thrift backend across the full
(clientId × clientSecret) input matrix (verified). Consequences vs the prior
id-presence routing:
- `oauthClientId` + no secret now runs U2M (browser) and forwards the id as a
custom U2M client (Thrift does the same).
- M2M with no/blank id no longer throws "id required" — it uses the default
client (`?? defaultClientId`), matching Thrift.
- A present-but-empty/`"undefined"` secret routes to M2M (not U2M), matching
Thrift's strict `=== undefined` check.
Trade-off (accepted for parity): this re-imports Thrift's env-stringification
behaviour — a secret/id env var that resolved to `""`/`"undefined"` is taken
literally rather than treated as unset.
Updated the auth unit tests (u2m/m2m/edge-cases) to assert the strict-parity
matrix.
Co-authored-by: Isaac
Signed-off-by: Madhavendra Rathore <madhavendra.rathore@databricks.com>
* chore(kernel): bump KERNEL_REV to kernel main (statement-level query tags + proxy + UA)
Bump the pinned kernel from b676275 to 34b4c20 (current kernel main), which
brings:
- #150 — per-statement query tags on the SEA wire (native query_tags array).
This is what makes `executeStatement(sql, { queryTags })` actually reach the
server on the kernel path — bringing statement-level query tags to parity
with the Thrift backend (the driver already serialized them into
statement_conf["query_tags"]; the kernel previously dropped that before the
wire). Verified e2e: the tag now lands in system.query.history.query_tags.
- #129 — programmatic HTTP/HTTPS proxy + per-connection socket timeout
(additive optional napi ConnectionOptions fields; refreshed in index.d.ts).
- #151 — caller User-Agent overwrites the kernel base UA for accurate
query-source attribution.
Refreshes the committed napi types (native/kernel/index.d.ts) accordingly; the
new fields are optional, so no driver-side change is required.
Co-authored-by: Isaac
Signed-off-by: Madhavendra Rathore <madhavendra.rathore@databricks.com>
---------
Signed-off-by: Madhavendra Rathore <madhavendra.rathore@databricks.com>1 parent 26be3be commit 3358a61
10 files changed
Lines changed: 349 additions & 271 deletions
File tree
- lib
- contracts
- kernel
- native/kernel
- tests/unit/kernel
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
25 | 29 | | |
26 | 30 | | |
27 | 31 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
28 | 28 | | |
29 | 29 | | |
30 | 30 | | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
31 | 50 | | |
32 | 51 | | |
33 | 52 | | |
| |||
189 | 208 | | |
190 | 209 | | |
191 | 210 | | |
| 211 | + | |
192 | 212 | | |
193 | 213 | | |
194 | 214 | | |
195 | 215 | | |
196 | 216 | | |
197 | 217 | | |
| 218 | + | |
| 219 | + | |
198 | 220 | | |
199 | 221 | | |
200 | 222 | | |
| |||
541 | 563 | | |
542 | 564 | | |
543 | 565 | | |
| 566 | + | |
544 | 567 | | |
545 | 568 | | |
546 | 569 | | |
| |||
579 | 602 | | |
580 | 603 | | |
581 | 604 | | |
582 | | - | |
583 | | - | |
584 | | - | |
585 | | - | |
586 | | - | |
587 | | - | |
588 | | - | |
589 | | - | |
590 | | - | |
591 | | - | |
592 | | - | |
593 | | - | |
594 | | - | |
595 | | - | |
596 | | - | |
597 | | - | |
598 | | - | |
599 | | - | |
600 | | - | |
601 | | - | |
602 | | - | |
603 | | - | |
604 | | - | |
605 | | - | |
606 | | - | |
607 | | - | |
608 | | - | |
609 | | - | |
610 | | - | |
611 | | - | |
612 | | - | |
613 | | - | |
614 | | - | |
615 | | - | |
| 605 | + | |
| 606 | + | |
| 607 | + | |
| 608 | + | |
| 609 | + | |
| 610 | + | |
| 611 | + | |
| 612 | + | |
| 613 | + | |
| 614 | + | |
| 615 | + | |
| 616 | + | |
616 | 617 | | |
617 | 618 | | |
618 | 619 | | |
| |||
623 | 624 | | |
624 | 625 | | |
625 | 626 | | |
626 | | - | |
| 627 | + | |
627 | 628 | | |
628 | | - | |
| 629 | + | |
629 | 630 | | |
| 631 | + | |
| 632 | + | |
| 633 | + | |
630 | 634 | | |
| 635 | + | |
| 636 | + | |
| 637 | + | |
| 638 | + | |
631 | 639 | | |
632 | 640 | | |
633 | | - | |
634 | | - | |
635 | | - | |
636 | | - | |
637 | | - | |
638 | | - | |
639 | | - | |
640 | | - | |
641 | | - | |
642 | | - | |
643 | | - | |
| 641 | + | |
644 | 642 | | |
645 | 643 | | |
646 | 644 | | |
| |||
650 | 648 | | |
651 | 649 | | |
652 | 650 | | |
653 | | - | |
| 651 | + | |
| 652 | + | |
654 | 653 | | |
| 654 | + | |
| 655 | + | |
| 656 | + | |
655 | 657 | | |
656 | 658 | | |
657 | 659 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
| 22 | + | |
22 | 23 | | |
23 | 24 | | |
24 | 25 | | |
| |||
145 | 146 | | |
146 | 147 | | |
147 | 148 | | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
148 | 163 | | |
149 | 164 | | |
150 | 165 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
156 | 156 | | |
157 | 157 | | |
158 | 158 | | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
159 | 166 | | |
160 | | - | |
161 | | - | |
162 | | - | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
163 | 173 | | |
164 | 174 | | |
165 | | - | |
166 | | - | |
167 | | - | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
168 | 181 | | |
169 | 182 | | |
170 | | - | |
171 | | - | |
172 | | - | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
173 | 189 | | |
174 | 190 | | |
175 | 191 | | |
| |||
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
0 commit comments