Skip to content

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
mainfrom
ai/issue-1570
Open

DatabaseMetaData.getTables: empty types[] matches none instead of all (should equal null) (#1570)#1611
peco-engineer-bot[bot] wants to merge 1 commit into
mainfrom
ai/issue-1570

Conversation

@peco-engineer-bot

Copy link
Copy Markdown

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.java
Planned coverage:

  • Live e2e test (integration/e2e/MetadataTests): create a table in the connection's catalog/schema, then call md.getTables(catalog, schema, tableName, new String[]{}) and assert the table IS listed — i.e. empty types[] matches all, identical to passing null. Currently returns 0 rows (red). Exercised through the default warehouse connection (getValidJDBCConnection). (Empty types[] must match all table types (match-all), same as null — the single divergence reported.)

Files changed

  • src/test/java/com/databricks/jdbc/integration/e2e/MetadataTests.java
  • src/main/java/com/databricks/jdbc/dbclient/impl/sqlexec/DatabricksMetadataQueryClient.java
  • src/main/java/com/databricks/jdbc/dbclient/impl/thrift/DatabricksThriftServiceClient.java
  • src/test/java/com/databricks/jdbc/dbclient/impl/thrift/DatabricksThriftServiceClientTest.java
  • NEXT_CHANGELOG.md

Test plan

  • com.databricks.jdbc.integration.e2e.MetadataTests#testGetTablesEmptyTypesMatchesAll — fails (red) against the original code, passes (green) after the fix
  • com.databricks.jdbc.dbclient.impl.thrift.DatabricksThriftServiceClientTest#testListTablesWithEmptyTypesMatchesAll — fails (red) against the original code, passes (green) after the fix

NO_CHANGELOG=true

🤖 Generated by engineer-bot (bug-fix flow) — review before merge.

… (should equal null) (#1570)

Signed-off-by: peco-engineer-bot[bot] <3815206+peco-engineer-bot[bot]@users.noreply.github.com>
@peco-engineer-bot peco-engineer-bot Bot added the engineer-bot Maintainer-only: triggers the autonomous engineer-bot (bug-fix author on issues; follow-up on PRs) label Aug 4, 2026

@peco-review-bot peco-review-bot Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ No issues identified by the review bot.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

engineer-bot Maintainer-only: triggers the autonomous engineer-bot (bug-fix author on issues; follow-up on PRs)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants