DatabaseMetaData.getTables: empty types[] matches none instead of all (should equal null) (#1570) - #1611
Open
peco-engineer-bot[bot] wants to merge 1 commit into
Open
DatabaseMetaData.getTables: empty types[] matches none instead of all (should equal null) (#1570)#1611peco-engineer-bot[bot] wants to merge 1 commit into
peco-engineer-bot[bot] wants to merge 1 commit into
Conversation
… (should equal null) (#1570) Signed-off-by: peco-engineer-bot[bot] <3815206+peco-engineer-bot[bot]@users.noreply.github.com>
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
Automated fix for #1570 — DatabaseMetaData.getTables: empty types[] matches none instead of all (should equal null).
In both listTables implementations (SEA DatabricksMetadataQueryClient and Thrift DatabricksThriftServiceClient) an empty types[] array is now normalized to null, so it carries no type constraint and matches ALL table types per the JDBC DatabaseMetaData.getTables contract (identical to passing null), replacing the prior match-none short-circuit. Verified with the live-warehouse e2e test and the Thrift unit test; spotless:check is clean.
Root cause & plan
Root cause: Both metadata client implementations short-circuit when getTables is passed an empty types[] array, returning an empty result set. In DatabricksMetadataQueryClient.listTables (SEA, lines 145-147) and DatabricksThriftServiceClient.listTables (Thrift, lines 516-518) there is an explicit
if (tableTypes != null && tableTypes.length == 0) return <empty result>guard with the comment "empty array = return nothing". This misreads the JDBC DatabaseMetaData.getTables contract: an empty (or null/absent) type list carries no type constraint and must match ALL table types (equivalent to null). The downstream filter in MetadataResultSetBuilder.getTablesResult already handles empty correctly (tableTypes != null && tableTypes.length > 0→ no filtering), so the early-return guards are the sole cause of the match-none behavior.Files:
jdbc-core/src/main/java/com/databricks/jdbc/dbclient/impl/sqlexec/DatabricksMetadataQueryClient.java,jdbc-core/src/main/java/com/databricks/jdbc/dbclient/impl/thrift/DatabricksThriftServiceClient.java,jdbc-core/src/test/java/com/databricks/jdbc/integration/e2e/MetadataTests.javaPlanned coverage:
Files changed
src/test/java/com/databricks/jdbc/integration/e2e/MetadataTests.javasrc/main/java/com/databricks/jdbc/dbclient/impl/sqlexec/DatabricksMetadataQueryClient.javasrc/main/java/com/databricks/jdbc/dbclient/impl/thrift/DatabricksThriftServiceClient.javasrc/test/java/com/databricks/jdbc/dbclient/impl/thrift/DatabricksThriftServiceClientTest.javaNEXT_CHANGELOG.mdTest plan
com.databricks.jdbc.integration.e2e.MetadataTests#testGetTablesEmptyTypesMatchesAll— fails (red) against the original code, passes (green) after the fixcom.databricks.jdbc.dbclient.impl.thrift.DatabricksThriftServiceClientTest#testListTablesWithEmptyTypesMatchesAll— fails (red) against the original code, passes (green) after the fixNO_CHANGELOG=true
🤖 Generated by engineer-bot (bug-fix flow) — review before merge.