Commit ec9a2ff
Return empty ResultSets for NULL catalog in metadata methods (#1128)
## Summary
Modified metadata methods to return empty ResultSets instead of throwing
validation exceptions when catalog parameter is NULL. This improves JDBC
spec compatibility and prevents errors in tools that pass NULL catalog
values.
## Changes
### DatabricksMetadataSdkClient.java
- `listColumns()`: Returns empty ResultSet when catalog is NULL
- `listFunctions()`: Returns empty ResultSet when catalog is NULL
- `listPrimaryKeys()`: Returns empty ResultSet when catalog, schema, or
table is NULL
- `listImportedKeys()`: Returns empty ResultSet when catalog, schema, or
table is NULL
### CommandBuilder.java
Removed `throwErrorIfNull` validation checks from:
- `fetchColumnsSQL()`
- `fetchFunctionsSQL()`
- `fetchPrimaryKeysSQL()`
- `fetchForeignKeysSQL()`
Validation is now handled at the client level by returning empty
ResultSets.
### DatabricksThriftServiceClient.java
- Added NULL catalog handling in `listFunctions()` for SQL command path
(when `EnableShowCommandForGetFunctions=1`)
### DatabricksMetadataSdkClientTest.java
- Updated test `testReturnsEmptyResultSetInCaseOfNullCatalog` (renamed
from `testThrowsErrorResultInCaseOfNullCatalog`)
- Verifies empty ResultSets are returned for NULL catalog instead of
throwing exceptions
## Test Results
All 467 metadata-related tests passing:
| Test Suite | Tests | Result |
|------------|-------|--------|
| DatabricksMetadataSdkClientTest | 33 | ✅ PASS |
| DatabricksThriftServiceClientTest | 39 | ✅ PASS |
| MetadataResultSetBuilderTest + Others | 150 | ✅ PASS |
| DatabricksDatabaseMetaDataTest | 245 | ✅ PASS |
## Behavior Change
**Before:** NULL catalog/schema/table parameters threw
`DatabricksValidationException`
**After:** NULL parameters return empty ResultSets with proper column
structure
## Affected Methods
- `DatabaseMetaData.getColumns(null, schema, table, column)`
- `DatabaseMetaData.getFunctions(null, schema, function)`
- `DatabaseMetaData.getPrimaryKeys(null, schema, table)`
- `DatabaseMetaData.getImportedKeys(null, schema, table)`
Fixes:
[PECOBLR-616](https://databricks.atlassian.net/browse/PECOBLR-616)
🤖 Generated with [Claude Code](https://claude.com/claude-code)
[PECOBLR-616]:
https://databricks.atlassian.net/browse/PECOBLR-616?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ
Co-authored-by: Claude <noreply@anthropic.com>
Co-authored-by: Samikshya Chand <148681192+samikshya-db@users.noreply.github.com>1 parent d330039 commit ec9a2ff
4 files changed
Lines changed: 93 additions & 11 deletions
File tree
- src
- main/java/com/databricks/jdbc/dbclient/impl
- sqlexec
- thrift
- test/java/com/databricks/jdbc/dbclient/impl/sqlexec
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
| 21 | + | |
21 | 22 | | |
22 | 23 | | |
23 | 24 | | |
Lines changed: 52 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
146 | 146 | | |
147 | 147 | | |
148 | 148 | | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
149 | 160 | | |
150 | 161 | | |
151 | 162 | | |
| |||
164 | 175 | | |
165 | 176 | | |
166 | 177 | | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
167 | 189 | | |
168 | 190 | | |
169 | 191 | | |
| |||
177 | 199 | | |
178 | 200 | | |
179 | 201 | | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
180 | 217 | | |
181 | 218 | | |
182 | 219 | | |
| |||
189 | 226 | | |
190 | 227 | | |
191 | 228 | | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
192 | 244 | | |
193 | 245 | | |
194 | 246 | | |
| |||
Lines changed: 9 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
516 | 516 | | |
517 | 517 | | |
518 | 518 | | |
| 519 | + | |
| 520 | + | |
| 521 | + | |
| 522 | + | |
| 523 | + | |
| 524 | + | |
| 525 | + | |
| 526 | + | |
| 527 | + | |
519 | 528 | | |
520 | 529 | | |
521 | 530 | | |
| |||
Lines changed: 31 additions & 11 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
23 | | - | |
24 | 23 | | |
25 | 24 | | |
26 | 25 | | |
| |||
788 | 787 | | |
789 | 788 | | |
790 | 789 | | |
791 | | - | |
| 790 | + | |
792 | 791 | | |
793 | 792 | | |
794 | 793 | | |
795 | 794 | | |
796 | | - | |
797 | | - | |
798 | | - | |
799 | | - | |
800 | | - | |
801 | | - | |
802 | | - | |
803 | | - | |
804 | | - | |
| 795 | + | |
| 796 | + | |
| 797 | + | |
| 798 | + | |
| 799 | + | |
| 800 | + | |
| 801 | + | |
| 802 | + | |
| 803 | + | |
| 804 | + | |
| 805 | + | |
| 806 | + | |
| 807 | + | |
| 808 | + | |
| 809 | + | |
| 810 | + | |
| 811 | + | |
| 812 | + | |
| 813 | + | |
| 814 | + | |
| 815 | + | |
| 816 | + | |
| 817 | + | |
| 818 | + | |
| 819 | + | |
| 820 | + | |
| 821 | + | |
| 822 | + | |
| 823 | + | |
| 824 | + | |
805 | 825 | | |
806 | 826 | | |
807 | 827 | | |
| |||
0 commit comments