Commit de95f1d
authored
Add SPOG support for ?o= routing in httpPath (#1316)
## Summary
SPOG (Single Panel of Glass) replaces workspace-specific hostnames with
account-level vanity URLs. When httpPath contains `?o=<workspaceId>`,
the driver needs to:
1. Preserve the `?o=` value through URL parsing
2. Extract the clean warehouse ID (without `?o=`) for SEA JSON body
3. Inject `x-databricks-org-id` header on endpoints that don't carry
`?o=` in the URL path (telemetry, feature flags, DBFS volume)
### Changes
**Fix 1 — Property parser** (`DatabricksConnectionContext.java`):
- `split("=")` broke httpPath values containing `=` (e.g.
`httpPath=/sql/1.0/warehouses/xxx?o=yyy` split into 3 parts, dropping
the workspace ID)
- Changed to `indexOf("=")` + `substring` to split on first `=` only
**Fix 2 — Warehouse ID regex** (`DatabricksJdbcConstants.java`):
- `(.+)` captured `abc123?o=999` as warehouse ID, corrupting SEA JSON
body
- Changed to `([^?]+).*` to stop capture at query params
- Trailing `.*` needed because Java `.matches()` requires full-string
match
**Fix 3 — SPOG header extraction** (`DatabricksConnectionContext.java`):
- Uses `URIBuilder` to parse `?o=<workspaceId>` from httpPath
- Injects `x-databricks-org-id` into `customHeaders` map
- Respects explicitly set header (won't override)
**Fix 4 — Header propagation** (telemetry, feature flags, DBFS volume):
- `TelemetryPushClient.java`: Added
`connectionContext.getCustomHeaders()` to telemetry POST
- `DatabricksDriverFeatureFlagsContext.java`: Added
`connectionContext.getCustomHeaders()` to feature flag GET
- `DBFSVolumeClient.java`: Added `connectionContext.getCustomHeaders()`
to all 5 HTTP request paths (4 sync + 1 async), with null guard for test
constructor
### What does NOT get the header
OAuth endpoints (`/oidc/v1/token`, OIDC discovery) — they are
workspace-agnostic and reject `x-databricks-org-id` with HTTP 400. These
use their own HTTP client and never see `customHeaders`.
## Context
Per the [SPOG Peco Clients
doc](https://docs.google.com/document/d/1ZTacOW72Jetr6Qo1iLVogeXKDYoFAE_R8_32KmLawmQ/):
- Thrift: `?o=` in the POST URL handles routing naturally
- SEA, telemetry, feature flags, DBFS volume: Need `x-databricks-org-id`
header since they use separate endpoint paths
Jira: [XTA-15079](https://databricks.atlassian.net/browse/XTA-15079)
## Test plan
**Unit tests added:**
- [x] `testBuildPropertiesMap_preservesQueryParamInHttpPath` — httpPath
with `?o=` preserved
- [x] `testBuildPropertiesMap_handlesValueWithMultipleEquals` — values
with multiple `=` preserved
- [x] `testBuildPropertiesMap_handlesValueWithNoEquals` — key-only
params handled
- [x] `testSpogContext_extractsOrgIdFromHttpPath` —
`x-databricks-org-id` extracted from `?o=`
- [x] `testSpogContext_extractsCleanWarehouseId` — warehouse ID is
`abc123` not `abc123?o=...`
- [x] `testSpogContext_noOrgIdWithoutQueryParam` — no header injected
for legacy URLs
- [x] `testSpogContext_explicitHeaderTakesPrecedence` — explicit
`http.header.x-databricks-org-id` wins over `?o=`
- [x] 3 SPOG URL validation tests in `ValidationUtilTest`
**E2E tested (not committed):**
- [x] DBSQL + PAT: Thrift and SEA on SPOG host
- [x] GP Cluster + PAT: Thrift on SPOG host
- [x] OAuth M2M: Thrift and SEA on SPOG host
- [x] OAuth U2M: Thrift and SEA on SPOG host (with browser login)
- [x] Telemetry: Verified 200 on SPOG with org-id header
- [x] Feature flags: Verified 200 on SPOG with org-id header
- [x] DBFS Volume LIST: Verified on SPOG host
- [x] Legacy host: All auth modes unaffected
NO_CHANGELOG=true
This pull request was AI-assisted by Isaac.
[XTA-15079]:
https://databricks.atlassian.net/browse/XTA-15079?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ
---------
Signed-off-by: Madhavendra Rathore <madhavendra.rathore@databricks.com>
Signed-off-by: Madhavendra Rathore1 parent a29d39b commit de95f1d
8 files changed
Lines changed: 169 additions & 19 deletions
File tree
- src
- main/java/com/databricks/jdbc
- api/impl
- volume
- common
- safe
- telemetry
- test/java/com/databricks/jdbc
- api/impl
- common/util
Lines changed: 52 additions & 12 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
29 | 29 | | |
30 | 30 | | |
31 | 31 | | |
| 32 | + | |
32 | 33 | | |
33 | 34 | | |
34 | 35 | | |
35 | 36 | | |
| 37 | + | |
36 | 38 | | |
37 | 39 | | |
38 | 40 | | |
| |||
108 | 110 | | |
109 | 111 | | |
110 | 112 | | |
111 | | - | |
112 | | - | |
113 | | - | |
114 | | - | |
115 | | - | |
116 | | - | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
117 | 119 | | |
118 | | - | |
| 120 | + | |
119 | 121 | | |
120 | 122 | | |
121 | 123 | | |
| |||
1166 | 1168 | | |
1167 | 1169 | | |
1168 | 1170 | | |
| 1171 | + | |
| 1172 | + | |
| 1173 | + | |
1169 | 1174 | | |
1170 | 1175 | | |
1171 | 1176 | | |
1172 | | - | |
1173 | | - | |
1174 | | - | |
1175 | | - | |
1176 | | - | |
| 1177 | + | |
| 1178 | + | |
| 1179 | + | |
| 1180 | + | |
| 1181 | + | |
| 1182 | + | |
| 1183 | + | |
| 1184 | + | |
| 1185 | + | |
| 1186 | + | |
| 1187 | + | |
| 1188 | + | |
| 1189 | + | |
| 1190 | + | |
| 1191 | + | |
| 1192 | + | |
| 1193 | + | |
| 1194 | + | |
| 1195 | + | |
| 1196 | + | |
| 1197 | + | |
| 1198 | + | |
| 1199 | + | |
| 1200 | + | |
| 1201 | + | |
| 1202 | + | |
| 1203 | + | |
| 1204 | + | |
| 1205 | + | |
| 1206 | + | |
| 1207 | + | |
| 1208 | + | |
| 1209 | + | |
| 1210 | + | |
| 1211 | + | |
| 1212 | + | |
| 1213 | + | |
| 1214 | + | |
| 1215 | + | |
| 1216 | + | |
1177 | 1217 | | |
1178 | 1218 | | |
1179 | 1219 | | |
| |||
Lines changed: 11 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
492 | 492 | | |
493 | 493 | | |
494 | 494 | | |
495 | | - | |
| 495 | + | |
| 496 | + | |
496 | 497 | | |
497 | 498 | | |
498 | 499 | | |
| |||
514 | 515 | | |
515 | 516 | | |
516 | 517 | | |
517 | | - | |
| 518 | + | |
| 519 | + | |
518 | 520 | | |
519 | 521 | | |
520 | 522 | | |
| |||
534 | 536 | | |
535 | 537 | | |
536 | 538 | | |
537 | | - | |
| 539 | + | |
| 540 | + | |
538 | 541 | | |
539 | 542 | | |
540 | 543 | | |
| |||
551 | 554 | | |
552 | 555 | | |
553 | 556 | | |
554 | | - | |
| 557 | + | |
| 558 | + | |
555 | 559 | | |
556 | 560 | | |
557 | 561 | | |
| |||
888 | 892 | | |
889 | 893 | | |
890 | 894 | | |
| 895 | + | |
| 896 | + | |
| 897 | + | |
891 | 898 | | |
892 | 899 | | |
893 | 900 | | |
| |||
Lines changed: 4 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
20 | | - | |
21 | | - | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
22 | 24 | | |
23 | 25 | | |
24 | 26 | | |
| |||
Lines changed: 1 addition & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
102 | 102 | | |
103 | 103 | | |
104 | 104 | | |
| 105 | + | |
105 | 106 | | |
106 | 107 | | |
107 | 108 | | |
| |||
Lines changed: 1 addition & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
59 | 59 | | |
60 | 60 | | |
61 | 61 | | |
| 62 | + | |
62 | 63 | | |
63 | 64 | | |
64 | 65 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
321 | 321 | | |
322 | 322 | | |
323 | 323 | | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
324 | 337 | | |
Lines changed: 79 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1358 | 1358 | | |
1359 | 1359 | | |
1360 | 1360 | | |
| 1361 | + | |
| 1362 | + | |
| 1363 | + | |
| 1364 | + | |
| 1365 | + | |
| 1366 | + | |
| 1367 | + | |
| 1368 | + | |
| 1369 | + | |
| 1370 | + | |
| 1371 | + | |
| 1372 | + | |
| 1373 | + | |
| 1374 | + | |
| 1375 | + | |
| 1376 | + | |
| 1377 | + | |
| 1378 | + | |
| 1379 | + | |
| 1380 | + | |
| 1381 | + | |
| 1382 | + | |
| 1383 | + | |
| 1384 | + | |
| 1385 | + | |
| 1386 | + | |
| 1387 | + | |
| 1388 | + | |
| 1389 | + | |
| 1390 | + | |
| 1391 | + | |
| 1392 | + | |
| 1393 | + | |
| 1394 | + | |
| 1395 | + | |
| 1396 | + | |
| 1397 | + | |
| 1398 | + | |
| 1399 | + | |
| 1400 | + | |
| 1401 | + | |
| 1402 | + | |
| 1403 | + | |
| 1404 | + | |
| 1405 | + | |
| 1406 | + | |
| 1407 | + | |
| 1408 | + | |
| 1409 | + | |
| 1410 | + | |
| 1411 | + | |
| 1412 | + | |
| 1413 | + | |
| 1414 | + | |
| 1415 | + | |
| 1416 | + | |
| 1417 | + | |
| 1418 | + | |
| 1419 | + | |
| 1420 | + | |
| 1421 | + | |
| 1422 | + | |
| 1423 | + | |
| 1424 | + | |
| 1425 | + | |
| 1426 | + | |
| 1427 | + | |
| 1428 | + | |
| 1429 | + | |
| 1430 | + | |
| 1431 | + | |
| 1432 | + | |
| 1433 | + | |
| 1434 | + | |
| 1435 | + | |
| 1436 | + | |
| 1437 | + | |
| 1438 | + | |
| 1439 | + | |
1361 | 1440 | | |
1362 | 1441 | | |
1363 | 1442 | | |
| |||
Lines changed: 8 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
128 | 128 | | |
129 | 129 | | |
130 | 130 | | |
131 | | - | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
132 | 139 | | |
133 | 140 | | |
0 commit comments