Commit 731b120
## Summary
Fixes GitHub issue #1141 where JDBC driver fails with
`INVALID_IDENTIFIER` error when catalog/schema/table names contain
hyphens or other special characters.
## Root Cause
Per [Databricks identifier
rules](https://docs.databricks.com/aws/en/sql/language-manual/sql-ref-identifiers),
identifiers with special characters must be enclosed in backticks. The
driver was missing backticks in SQL template generation.
## Changes Made
### 1. CommandConstants.java (4 SQL templates)
- `IN_CATALOG_SQL`: Added backticks → `" IN CATALOG \`%s\`"`
- `IN_ABSOLUTE_SCHEMA_SQL`: Added backticks → `" IN SCHEMA \`%s\`"`
- `IN_ABSOLUTE_TABLE_SQL`: Added backticks → `" IN TABLE \`%s\`"`
- `SHOW_SCHEMAS_IN_CATALOG_SQL`: Added backticks → `"SHOW SCHEMAS IN
\`%s\`"`
**Affects commands:**
- SHOW SCHEMAS IN <catalog>
- SHOW TABLES IN CATALOG <catalog>
- SHOW COLUMNS IN CATALOG <catalog>
- SHOW FUNCTIONS IN CATALOG <catalog>
- SHOW KEYS IN CATALOG <catalog> IN SCHEMA <schema> IN TABLE <table>
- SHOW FOREIGN KEYS IN CATALOG <catalog> IN SCHEMA <schema> IN TABLE
<table>
### 2. DatabricksConnection.java (2 methods)
- `setCatalog()`: Added backticks → `"SET CATALOG \`" + catalog + "\`"`
- `setSchema()`: Added backticks → `"USE SCHEMA \`" + schema + "\`"`
### 3. Test Coverage
- **Unit test**:
`DatabricksConnectionTest#testSetCatalogAndSchemaWithHyphenatedIdentifiers`
- Tests setCatalog() and setSchema() with mocked client
- Verifies correct SQL generation with backticks
- **Integration test**:
`MetadataIntegrationTests#testMetadataOperationsWithHyphenatedIdentifiers`
- Tests getTables() and getColumns() with hyphenated schema/table names
- Includes stub mappings for SEA client (SQL Execution API)
- All tests passing ✅
- **Example test**: `DatabricksDriverExamples#exampleHyphenTesting`
- Manual validation test for end-to-end verification
## Test Results
```
✅ DatabricksConnectionTest: Tests run: 1, Failures: 0, Errors: 0
✅ MetadataIntegrationTests: Tests run: 1, Failures: 0, Errors: 0
```
## Test plan
- [x] Unit tests pass for setCatalog/setSchema with hyphenated
identifiers
- [x] Integration tests pass for metadata operations (getTables,
getColumns)
- [x] Manually tested with real Databricks warehouse
(exampleHyphenTesting)
- [x] Verified backticks don't break normal identifiers (backward
compatible)
- [x] Tested with SEA client (SQL Execution API)
- [x] Generated stub mappings for regression testing
## Related Issues
Fixes #1141
Fixes
[PECOBLR-1398](https://databricks.atlassian.net/browse/PECOBLR-1398)
🤖 Generated with [Claude Code](https://claude.com/claude-code)
[PECOBLR-1398]:
https://databricks.atlassian.net/browse/PECOBLR-1398?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ
---------
Signed-off-by: Madhavendra Rathore <madhavendra.rathore@databricks.com>
Co-authored-by: Claude <noreply@anthropic.com>
1 parent d37847f commit 731b120
43 files changed
Lines changed: 1178 additions & 73 deletions
File tree
- src
- main/java/com/databricks/jdbc
- api/impl
- dbclient/impl/common
- test
- java/com/databricks/jdbc
- api/impl
- dbclient/impl
- sqlexec
- thrift
- integration/fakeservice/tests
- resources
- cloudfetchapi/metadataintegrationtests
- testcatalogandschemainformation/mappings
- testmetadataoperationswithhyphenatedidentifiers/mappings
- sqlexecapi
- enablemultiplecatalogsupportintegrationtests/testgetschemaswithnullcatalogmultiplecatalogsupportdisabled/mappings
- metadataintegrationtests
- testcatalogandschemainformation/mappings
- testmetadataoperationswithhyphenatedidentifiers/mappings
- thriftserverapi/metadataintegrationtests/testmetadataoperationswithhyphenatedidentifiers/mappings
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
| 18 | + | |
18 | 19 | | |
19 | 20 | | |
20 | 21 | | |
Lines changed: 2 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
446 | 446 | | |
447 | 447 | | |
448 | 448 | | |
449 | | - | |
| 449 | + | |
450 | 450 | | |
451 | 451 | | |
452 | 452 | | |
| |||
811 | 811 | | |
812 | 812 | | |
813 | 813 | | |
814 | | - | |
| 814 | + | |
815 | 815 | | |
816 | 816 | | |
817 | 817 | | |
| |||
Lines changed: 4 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
11 | | - | |
12 | | - | |
13 | | - | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
14 | 14 | | |
15 | | - | |
| 15 | + | |
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
| |||
Lines changed: 54 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
101 | 101 | | |
102 | 102 | | |
103 | 103 | | |
104 | | - | |
| 104 | + | |
105 | 105 | | |
106 | 106 | | |
107 | 107 | | |
108 | 108 | | |
109 | 109 | | |
110 | 110 | | |
111 | 111 | | |
112 | | - | |
| 112 | + | |
113 | 113 | | |
114 | 114 | | |
115 | 115 | | |
| |||
124 | 124 | | |
125 | 125 | | |
126 | 126 | | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
127 | 177 | | |
128 | 178 | | |
129 | 179 | | |
| |||
156 | 206 | | |
157 | 207 | | |
158 | 208 | | |
159 | | - | |
| 209 | + | |
160 | 210 | | |
161 | 211 | | |
162 | 212 | | |
| |||
167 | 217 | | |
168 | 218 | | |
169 | 219 | | |
170 | | - | |
| 220 | + | |
171 | 221 | | |
172 | 222 | | |
173 | 223 | | |
| |||
Lines changed: 29 additions & 57 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
49 | 49 | | |
50 | 50 | | |
51 | 51 | | |
52 | | - | |
| 52 | + | |
53 | 53 | | |
54 | 54 | | |
55 | 55 | | |
56 | 56 | | |
57 | 57 | | |
58 | | - | |
| 58 | + | |
59 | 59 | | |
60 | 60 | | |
61 | 61 | | |
62 | 62 | | |
63 | 63 | | |
64 | | - | |
| 64 | + | |
65 | 65 | | |
66 | 66 | | |
67 | 67 | | |
68 | 68 | | |
69 | 69 | | |
70 | | - | |
| 70 | + | |
71 | 71 | | |
72 | 72 | | |
73 | 73 | | |
| |||
76 | 76 | | |
77 | 77 | | |
78 | 78 | | |
79 | | - | |
80 | | - | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
81 | 82 | | |
82 | 83 | | |
83 | 84 | | |
84 | 85 | | |
85 | 86 | | |
86 | | - | |
| 87 | + | |
87 | 88 | | |
88 | 89 | | |
89 | 90 | | |
90 | 91 | | |
91 | 92 | | |
92 | | - | |
| 93 | + | |
93 | 94 | | |
94 | 95 | | |
95 | 96 | | |
96 | 97 | | |
97 | 98 | | |
98 | | - | |
| 99 | + | |
99 | 100 | | |
100 | 101 | | |
101 | 102 | | |
| |||
105 | 106 | | |
106 | 107 | | |
107 | 108 | | |
108 | | - | |
| 109 | + | |
109 | 110 | | |
110 | 111 | | |
111 | 112 | | |
112 | 113 | | |
113 | 114 | | |
114 | 115 | | |
115 | | - | |
| 116 | + | |
116 | 117 | | |
117 | 118 | | |
118 | 119 | | |
119 | 120 | | |
120 | 121 | | |
121 | 122 | | |
122 | | - | |
| 123 | + | |
123 | 124 | | |
124 | 125 | | |
125 | 126 | | |
126 | 127 | | |
127 | 128 | | |
128 | 129 | | |
129 | | - | |
| 130 | + | |
130 | 131 | | |
131 | 132 | | |
132 | 133 | | |
133 | 134 | | |
134 | 135 | | |
135 | 136 | | |
136 | | - | |
| 137 | + | |
137 | 138 | | |
138 | 139 | | |
139 | 140 | | |
140 | 141 | | |
141 | 142 | | |
142 | 143 | | |
143 | | - | |
| 144 | + | |
144 | 145 | | |
145 | 146 | | |
146 | 147 | | |
147 | 148 | | |
148 | 149 | | |
149 | 150 | | |
150 | | - | |
| 151 | + | |
151 | 152 | | |
152 | 153 | | |
153 | 154 | | |
154 | 155 | | |
155 | 156 | | |
156 | 157 | | |
157 | | - | |
| 158 | + | |
158 | 159 | | |
159 | 160 | | |
160 | 161 | | |
| |||
453 | 454 | | |
454 | 455 | | |
455 | 456 | | |
456 | | - | |
| 457 | + | |
457 | 458 | | |
458 | 459 | | |
459 | 460 | | |
| |||
489 | 490 | | |
490 | 491 | | |
491 | 492 | | |
492 | | - | |
| 493 | + | |
493 | 494 | | |
494 | 495 | | |
495 | 496 | | |
| |||
537 | 538 | | |
538 | 539 | | |
539 | 540 | | |
540 | | - | |
| 541 | + | |
541 | 542 | | |
542 | 543 | | |
543 | 544 | | |
| |||
596 | 597 | | |
597 | 598 | | |
598 | 599 | | |
599 | | - | |
| 600 | + | |
600 | 601 | | |
601 | 602 | | |
602 | 603 | | |
| |||
674 | 675 | | |
675 | 676 | | |
676 | 677 | | |
677 | | - | |
| 678 | + | |
678 | 679 | | |
679 | 680 | | |
680 | 681 | | |
| |||
703 | 704 | | |
704 | 705 | | |
705 | 706 | | |
706 | | - | |
| 707 | + | |
707 | 708 | | |
708 | 709 | | |
709 | 710 | | |
| |||
932 | 933 | | |
933 | 934 | | |
934 | 935 | | |
935 | | - | |
| 936 | + | |
936 | 937 | | |
937 | 938 | | |
938 | 939 | | |
| |||
958 | 959 | | |
959 | 960 | | |
960 | 961 | | |
961 | | - | |
962 | | - | |
963 | | - | |
964 | | - | |
965 | | - | |
966 | 962 | | |
967 | 963 | | |
968 | | - | |
969 | | - | |
970 | 964 | | |
971 | 965 | | |
972 | | - | |
973 | | - | |
| 966 | + | |
974 | 967 | | |
975 | 968 | | |
976 | 969 | | |
| |||
979 | 972 | | |
980 | 973 | | |
981 | 974 | | |
982 | | - | |
| 975 | + | |
983 | 976 | | |
984 | 977 | | |
985 | 978 | | |
| |||
1032 | 1025 | | |
1033 | 1026 | | |
1034 | 1027 | | |
1035 | | - | |
| 1028 | + | |
1036 | 1029 | | |
1037 | 1030 | | |
1038 | 1031 | | |
| |||
1057 | 1050 | | |
1058 | 1051 | | |
1059 | 1052 | | |
1060 | | - | |
| 1053 | + | |
1061 | 1054 | | |
1062 | 1055 | | |
1063 | 1056 | | |
| |||
1078 | 1071 | | |
1079 | 1072 | | |
1080 | 1073 | | |
1081 | | - | |
1082 | | - | |
1083 | | - | |
1084 | | - | |
1085 | | - | |
1086 | | - | |
1087 | | - | |
1088 | | - | |
1089 | | - | |
1090 | | - | |
1091 | | - | |
1092 | | - | |
1093 | | - | |
1094 | | - | |
1095 | | - | |
1096 | | - | |
1097 | | - | |
1098 | | - | |
1099 | | - | |
1100 | | - | |
1101 | | - | |
1102 | 1074 | | |
0 commit comments