Commit 61574e5
Add UseQueryForMetadata connection property for Thrift metadata operations (#1242)
## Summary
- Add opt-in connection property `UseQueryForMetadata` that makes the
Thrift path use SQL SHOW commands (via `DatabricksMetadataQueryClient`)
instead of native Thrift RPCs for metadata operations
- Rename `DatabricksMetadataSdkClient` → `DatabricksMetadataQueryClient`
and internal field `sdkClient` → `queryExecutionClient` since the class
now serves both SEA and Thrift paths
## Problem
Thrift metadata operations (`GetTables`, `GetSchemas`, `GetColumns`,
etc.) pass filter patterns directly to the server, which treats `_` as a
single-character wildcard. This causes incorrect results — e.g.,
querying for catalog `a_b` also returns `axb`, `a1b`, etc.
The SEA metadata path already solved this by using SQL SHOW commands
with `LIKE` patterns (via `CommandBuilder` + `WildcardUtil`), which
handle `_` correctly.
## Solution
When `UseQueryForMetadata=1` and the client type is THRIFT,
`DatabricksSession` creates a `DatabricksMetadataQueryClient` wrapping
the Thrift `IDatabricksClient`. This reuses the entire SEA metadata
implementation — no code duplication needed — because
`DatabricksMetadataQueryClient` only calls `executeStatement()` and
`getConnectionContext()` on the underlying client, both of which
`DatabricksThriftServiceClient` already implements.
### How it works
**`DatabricksSession.getDatabricksMetadataClient()`:**
- **THRIFT + `UseQueryForMetadata=0` (default):** returns the Thrift
client cast to `IDatabricksMetadataClient` (unchanged behavior)
- **THRIFT + `UseQueryForMetadata=1`:** returns a
`DatabricksMetadataQueryClient` wrapping the Thrift client, which
executes SHOW SQL commands for metadata
- **SEA:** returns `DatabricksMetadataQueryClient` as before
The feature is also correctly wired in all SEA→Thrift fallback paths
(temporary redirect and rate limit).
## Changes
| File | Change |
|------|--------|
| `DatabricksJdbcUrlParams.java` | Add `USE_QUERY_FOR_METADATA` enum
constant |
| `IDatabricksConnectionContext.java` | Add `useQueryForMetadata()`
interface method |
| `DatabricksConnectionContext.java` | Implement `useQueryForMetadata()`
accessor |
| `DatabricksSession.java` | Create `DatabricksMetadataQueryClient` for
Thrift when enabled; update `getDatabricksMetadataClient()` dispatch;
handle SEA→Thrift fallback paths |
| `DatabricksMetadataSdkClient.java` →
`DatabricksMetadataQueryClient.java` | Rename class + rename `sdkClient`
field → `queryExecutionClient` |
| `DatabricksSessionTest.java` | Add tests for enabled/disabled dispatch
behavior |
| `DatabricksMetadataSdkClientTest.java` →
`DatabricksMetadataQueryClientTest.java` | Rename test class |
| `NEXT_CHANGELOG.md` | Add changelog entry |
## Backward Compatibility
- **Opt-in only:** `UseQueryForMetadata=0` by default — existing Thrift
behavior is completely unchanged
- **Independent of `EnableShowCommandForGetFunctions`:** that property
continues to work separately
- **SEA path unchanged:** `DatabricksMetadataQueryClient` is still used
for SEA as before
## Test plan
- [x] `DatabricksSessionTest` — 16/16 pass (includes 2 new tests
verifying dispatch with `UseQueryForMetadata=1` and default)
- [x] `DatabricksMetadataQueryClientTest` — 44/44 pass (all existing
metadata tests pass with renamed class)
- [x] `mvn spotless:check` — clean
- [x] `mvn clean install -DskipTests` — builds successfully
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Signed-off-by: Gopal Lal <gopal.lal@databricks.com>
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>1 parent a4eb66d commit 61574e5
8 files changed
Lines changed: 158 additions & 49 deletions
File tree
- src
- main/java/com/databricks/jdbc
- api
- impl
- internal
- common
- dbclient/impl/sqlexec
- test/java/com/databricks/jdbc
- api/impl
- dbclient/impl/sqlexec
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| 7 | + | |
7 | 8 | | |
8 | 9 | | |
9 | 10 | | |
| |||
Lines changed: 5 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1098 | 1098 | | |
1099 | 1099 | | |
1100 | 1100 | | |
| 1101 | + | |
| 1102 | + | |
| 1103 | + | |
| 1104 | + | |
| 1105 | + | |
1101 | 1106 | | |
1102 | 1107 | | |
1103 | 1108 | | |
| |||
Lines changed: 26 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
17 | | - | |
| 17 | + | |
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
| |||
84 | 84 | | |
85 | 85 | | |
86 | 86 | | |
87 | | - | |
88 | | - | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
89 | 90 | | |
90 | 91 | | |
91 | 92 | | |
| |||
141 | 142 | | |
142 | 143 | | |
143 | 144 | | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
144 | 150 | | |
145 | 151 | | |
146 | 152 | | |
147 | 153 | | |
148 | 154 | | |
149 | | - | |
| 155 | + | |
150 | 156 | | |
151 | 157 | | |
152 | 158 | | |
| |||
161 | 167 | | |
162 | 168 | | |
163 | 169 | | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
164 | 177 | | |
165 | 178 | | |
166 | 179 | | |
| |||
180 | 193 | | |
181 | 194 | | |
182 | 195 | | |
183 | | - | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
184 | 203 | | |
185 | 204 | | |
186 | 205 | | |
| |||
239 | 258 | | |
240 | 259 | | |
241 | 260 | | |
242 | | - | |
| 261 | + | |
| 262 | + | |
243 | 263 | | |
244 | 264 | | |
245 | 265 | | |
| |||
Lines changed: 2 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
405 | 405 | | |
406 | 406 | | |
407 | 407 | | |
| 408 | + | |
| 409 | + | |
408 | 410 | | |
409 | 411 | | |
410 | 412 | | |
| |||
Lines changed: 4 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
168 | 168 | | |
169 | 169 | | |
170 | 170 | | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
171 | 175 | | |
172 | 176 | | |
173 | 177 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
25 | 25 | | |
26 | 26 | | |
27 | 27 | | |
28 | | - | |
| 28 | + | |
29 | 29 | | |
30 | 30 | | |
31 | | - | |
| 31 | + | |
32 | 32 | | |
33 | 33 | | |
34 | 34 | | |
35 | 35 | | |
36 | | - | |
| 36 | + | |
37 | 37 | | |
38 | 38 | | |
39 | | - | |
40 | | - | |
41 | | - | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
42 | 43 | | |
43 | 44 | | |
44 | 45 | | |
| |||
381 | 382 | | |
382 | 383 | | |
383 | 384 | | |
384 | | - | |
385 | | - | |
| 385 | + | |
| 386 | + | |
386 | 387 | | |
387 | 388 | | |
388 | 389 | | |
| |||
406 | 407 | | |
407 | 408 | | |
408 | 409 | | |
409 | | - | |
| 410 | + | |
410 | 411 | | |
411 | 412 | | |
412 | 413 | | |
| |||
Lines changed: 78 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
16 | | - | |
| 16 | + | |
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
| |||
101 | 101 | | |
102 | 102 | | |
103 | 103 | | |
104 | | - | |
| 104 | + | |
105 | 105 | | |
106 | 106 | | |
107 | 107 | | |
| |||
294 | 294 | | |
295 | 295 | | |
296 | 296 | | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 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 | + | |
297 | 373 | | |
0 commit comments