Repository navigation
Use SHOW COLUMNS IN ALL CATALOGS for getColumns with null catalog - #1576
Closed
msrathore-db wants to merge 2 commits into
Closed
msrathore-db wants to merge 2 commits into
msrathore-db wants to merge 2 commits into
Conversation
getColumns(null, ...) previously enumerated every catalog via SHOW CATALOGS and issued a per-catalog SHOW COLUMNS, fanning out across a thread pool. This mirrors the older getSchemas/getTables behavior that has since moved to a single SHOW ... IN ALL CATALOGS statement. This change makes getColumns consistent: a null catalog now emits a single "SHOW COLUMNS IN ALL CATALOGS" statement (with the usual SCHEMA/TABLE/column LIKE clauses), letting the server enumerate catalogs in one call. The result schema is identical to per-catalog SHOW COLUMNS (the catalogName column is populated per row), so no result-mapping changes are needed. Older DBR versions that don't support the syntax return a parse syntax error, which is caught and transparently falls back to the previous enumerate-and-fan-out path (matching the getSchemas fallback). Co-authored-by: Isaac Signed-off-by: Madhavendra Rathore <[email protected]>
sreekanth-db
approved these changes
Jul 24, 2026
…olumns-all-catalogs
msrathore-db
added a commit
that referenced
this pull request
Jul 28, 2026
…me-repo, integration-test verification) (#1580) ## Summary Same change as #1576, pushed as a **same-repo branch** (not a fork) so the integration-test gate runs with a write-scoped token. The fork PR (#1576) had `skip-integration-tests-pr` fail with `403 Resource not accessible by integration` purely because a fork's `GITHUB_TOKEN` is read-only — this PR verifies the integration checks pass on a same-repo branch. `DatabaseMetaData.getColumns(catalog=null, ...)` now issues a single `SHOW COLUMNS IN ALL CATALOGS` statement (consistent with `getSchemas`/`getTables`) instead of enumerating every catalog and issuing a per-catalog `SHOW COLUMNS`. Older DBR versions that don't support the syntax fall back to the previous enumerate-and-fan-out behavior on a parse syntax error. ## Details - `CommandConstants`: add `SHOW_COLUMNS_IN_ALL_CATALOGS_SQL`. - `CommandBuilder.fetchColumnsSQL`: emit `SHOW COLUMNS IN ALL CATALOGS` when `catalogName == null` (mirrors `fetchTablesSQL` / `fetchSchemaSQL`). - `DatabricksMetadataQueryClient.listColumns`: null-catalog request goes through the normal path; on a parse syntax error it falls back to `fetchColumnsAcrossCatalogs`, exactly like `listSchemas`. The `SHOW COLUMNS IN ALL CATALOGS` result schema is identical to per-catalog `SHOW COLUMNS` (the `catalogName` column is populated per row), verified against a real SQL warehouse, so `COLUMN_COLUMNS` mapping needs no changes. ## Testing - Verified `SHOW COLUMNS IN ALL CATALOGS SCHEMA LIKE '…' TABLE LIKE '…'` succeeds against a real SQL warehouse and returns the expected 13-column schema with `catalogName` populated per row. - Added `CommandBuilderTest` null-catalog cases and `DatabricksMetadataQueryClientTest` tests for both the single-statement path and the parse-error fallback. - Full metadata suites green locally. This pull request and its description were written by Isaac. Signed-off-by: Madhavendra Rathore <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
DatabaseMetaData.getColumns(catalog=null, ...)previously enumerated every catalog withSHOW CATALOGSand then issued a separateSHOW COLUMNS IN CATALOG \`for each one, fanning the calls out across a metadata thread pool. This predates the server-side support forSHOW ... IN ALL CATALOGS, whichgetSchemasandgetTables` already use for the null-catalog case.This PR makes
getColumnsconsistent with the other metadata calls: when the catalog isnull, the driver now emits a singleSHOW COLUMNS IN ALL CATALOGSstatement (plus the usualSCHEMA LIKE/TABLE LIKE/ columnLIKEclauses) and lets the server enumerate catalogs in one round trip.Details
CommandConstants: addSHOW_COLUMNS_IN_ALL_CATALOGS_SQL.CommandBuilder.fetchColumnsSQL: emitSHOW COLUMNS IN ALL CATALOGSwhencatalogName == null(mirrorsfetchTablesSQL/fetchSchemaSQL); the LIKE-clause building is unchanged.DatabricksMetadataQueryClient.listColumns: drop the up-front "enumerate catalogs" branch. The null-catalog request now goes through the normal path; on a parse syntax error (older DBR versions that don't support the syntax) it transparently falls back to the previous enumerate-and-fan-out behavior (fetchColumnsAcrossCatalogs), exactly like thelistSchemasfallback.The
SHOW COLUMNS IN ALL CATALOGSresult schema is identical to per-catalogSHOW COLUMNS— thecatalogNamecolumn is populated per row — soCOLUMN_COLUMNSmapping (TABLE_CAT←catalogName) needs no changes.Testing
SHOW COLUMNS IN ALL CATALOGS SCHEMA LIKE '…' TABLE LIKE '…'succeeds against a real SQL warehouse and returns the expected 13-column schema withcatalogNamepopulated per row.CommandBuilderTest: added null-catalog cases assertingSHOW COLUMNS IN ALL CATALOGSwith and without LIKE clauses.DatabricksMetadataQueryClientTest: addedtestListColumnsAllCatalogs(single-statement path, no catalog enumeration) andtestListColumnsAllCatalogs_fallsBackOnParseSyntaxError(fallback to enumerate-and-fan-out).DatabricksMetadataQueryClientTest,CommandBuilderTest,MetadataResultSetBuilderTest,DatabricksSdkClientTest,DatabricksDatabaseMetaDataTest.This pull request and its description were written by Isaac.