Commit 9e96f22
authored
Fix getSchemas returning JDBC-escaped catalog name in SEA mode (#1365)
## Summary
Fixes SEA/Thrift parity issue where `getSchemas()` returns
`comparator\_tests` (with escaped underscore) instead of
`comparator_tests` in the `TABLE_CATALOG` column when using SEA mode
(`useThriftClient=0`).
### Root Cause
In `DatabricksMetadataQueryClient.listSchemas()`, the `catalog`
parameter from the JDBC caller can contain JDBC escape sequences (e.g.,
`comparator\_tests` where `\_` escapes the `_` wildcard). The
`CommandBuilder` correctly strips these escapes for the SQL query (`SHOW
SCHEMAS IN \`comparator_tests\``), but the **original escaped value**
was passed to `getSchemasResult()`.
Since `SHOW SCHEMAS IN \`catalog\`` doesn't return a `catalog` column
from the server (only `SHOW SCHEMAS IN ALL CATALOGS` does), the client
falls back to populating `TABLE_CATALOG` from the passed parameter —
inserting the JDBC-escaped value.
### Fix
Strip JDBC escapes from the `catalog` parameter via
`WildcardUtil.stripJdbcEscapes()` before passing it to
`getSchemasResult()`.
### Verification
The `EscapedUnderscoreTest` in `../example` can be used to verify
end-to-end:
```bash
cd ../example
mvn exec:java -Dexec.mainClass="com.databricks.example.EscapedUnderscoreTest"
```
Expected: Both Thrift and SEA should return `comparator_tests` (without
backslash) in TABLE_CATALOG for both escaped and unescaped input.
## Test plan
- [x] New unit test: `testListSchemasWithEscapedUnderscoreCatalog` —
verifies TABLE_CATALOG is unescaped
- [x] All 52 existing metadata query client tests pass
- [ ] Manual verification with `EscapedUnderscoreTest` against live
environment
This pull request was AI-assisted by Isaac.
---------
Signed-off-by: Gopal Lal <gopal.lal@databricks.com>1 parent d8bc48a commit 9e96f22
3 files changed
Lines changed: 79 additions & 1 deletion
File tree
- src
- main/java/com/databricks/jdbc/dbclient/impl/sqlexec
- test/java/com/databricks/jdbc/dbclient/impl/sqlexec
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
| 13 | + | |
13 | 14 | | |
14 | 15 | | |
15 | 16 | | |
| |||
Lines changed: 19 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
| 12 | + | |
12 | 13 | | |
13 | 14 | | |
14 | 15 | | |
| |||
98 | 99 | | |
99 | 100 | | |
100 | 101 | | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
101 | 109 | | |
102 | 110 | | |
103 | | - | |
| 111 | + | |
104 | 112 | | |
105 | 113 | | |
106 | 114 | | |
| |||
426 | 434 | | |
427 | 435 | | |
428 | 436 | | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
429 | 447 | | |
430 | 448 | | |
431 | 449 | | |
| |||
Lines changed: 59 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
458 | 458 | | |
459 | 459 | | |
460 | 460 | | |
| 461 | + | |
| 462 | + | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
| 466 | + | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
| 470 | + | |
| 471 | + | |
| 472 | + | |
| 473 | + | |
| 474 | + | |
| 475 | + | |
| 476 | + | |
| 477 | + | |
| 478 | + | |
| 479 | + | |
| 480 | + | |
| 481 | + | |
| 482 | + | |
| 483 | + | |
| 484 | + | |
| 485 | + | |
| 486 | + | |
| 487 | + | |
| 488 | + | |
| 489 | + | |
| 490 | + | |
| 491 | + | |
| 492 | + | |
| 493 | + | |
| 494 | + | |
| 495 | + | |
| 496 | + | |
| 497 | + | |
| 498 | + | |
| 499 | + | |
| 500 | + | |
| 501 | + | |
| 502 | + | |
| 503 | + | |
| 504 | + | |
461 | 505 | | |
462 | 506 | | |
463 | 507 | | |
| |||
717 | 761 | | |
718 | 762 | | |
719 | 763 | | |
| 764 | + | |
| 765 | + | |
| 766 | + | |
| 767 | + | |
| 768 | + | |
| 769 | + | |
| 770 | + | |
| 771 | + | |
| 772 | + | |
| 773 | + | |
| 774 | + | |
| 775 | + | |
| 776 | + | |
| 777 | + | |
| 778 | + | |
720 | 779 | | |
721 | 780 | | |
722 | 781 | | |
| |||
0 commit comments