Commit 727db4c
authored
Fix getTables(types=[]) returning rows in Thrift mode (#1451)
## Summary
- Per JDBC spec, `DatabaseMetaData.getTables(_, _, _, new String[0])`
(empty `types` array) means "no types selected" and should return zero
rows. The Thrift path was leaking rows because the post-server filter at
`MetadataResultSetBuilder.getTablesResult` is guarded by
`tableTypes.length > 0`, which short-circuits the filter for empty
arrays.
- Symptom: legacy `hive_metastore` objects have `TABLE_TYPE=""` from the
Thrift server. The client normalizes `""` → `"TABLE"`, and with the
broken filter guard those rows survived even for `types=[]`.
- Fix: mirror SEA's existing guard
(`DatabricksMetadataQueryClient.java:128-131`) in the Thrift
`listTables` — short-circuit to an empty result set at the top of the
method when `tableTypes` is non-null and length 0. The server is never
queried.
## Test plan
- [x] Added `testListTablesWithEmptyTypesReturnsEmptyWithoutServerCall`
— asserts zero rows AND that `thriftAccessor.getThriftResponse` is never
invoked
- [x] Existing `testListTables` (non-empty types) still passes — 46/46
in `DatabricksThriftServiceClientTest`
- [x] Verified end-to-end against a real workspace: before fix,
`getTables(null, null, null, [])` on Thrift returned 2
`hive_metastore.default.trim_repro*` rows while SEA returned 0; after
fix, both return 0
This pull request and its description were written by Isaac.
Signed-off-by: Sreekanth Vadigi <sreekanth.vadigi@databricks.com>1 parent 722d80a commit 727db4c
3 files changed
Lines changed: 22 additions & 0 deletions
File tree
- src
- main/java/com/databricks/jdbc/dbclient/impl/thrift
- test/java/com/databricks/jdbc/dbclient/impl/thrift
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
| 23 | + | |
23 | 24 | | |
24 | 25 | | |
25 | 26 | | |
| |||
Lines changed: 5 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
476 | 476 | | |
477 | 477 | | |
478 | 478 | | |
| 479 | + | |
| 480 | + | |
| 481 | + | |
| 482 | + | |
| 483 | + | |
479 | 484 | | |
480 | 485 | | |
481 | 486 | | |
| |||
Lines changed: 16 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
| 16 | + | |
16 | 17 | | |
17 | 18 | | |
18 | 19 | | |
| |||
590 | 591 | | |
591 | 592 | | |
592 | 593 | | |
| 594 | + | |
| 595 | + | |
| 596 | + | |
| 597 | + | |
| 598 | + | |
| 599 | + | |
| 600 | + | |
| 601 | + | |
| 602 | + | |
| 603 | + | |
| 604 | + | |
| 605 | + | |
| 606 | + | |
| 607 | + | |
| 608 | + | |
593 | 609 | | |
594 | 610 | | |
595 | 611 | | |
| |||
0 commit comments