Fix getTables(types=[]) returning rows in Thrift mode#1451
Merged
Conversation
Per JDBC spec, an empty `types` array passed to DatabaseMetaData.getTables() means "no types selected" and should return zero rows. The Thrift path was leaking rows because the client-side filter at MetadataResultSetBuilder.getTablesResult() is guarded by `tableTypes.length > 0`, which short-circuits the filter for empty arrays — letting all rows from the server pass through. This was visible for legacy hive_metastore objects, whose TABLE_TYPE the Thrift server returns as an empty string. The client normalizes "" → "TABLE", and with the broken filter guard those rows survived. Fix: mirror SEA's existing guard (DatabricksMetadataQueryClient.java:128-131) in the Thrift path — short-circuit to an empty result set at the top of listTables when tableTypes is non-null and length 0. The server is never queried. Co-authored-by: Isaac Signed-off-by: Sreekanth Vadigi <sreekanth.vadigi@databricks.com>
gopalldb
approved these changes
May 18, 2026
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.getTables(_, _, _, new String[0])(emptytypesarray) means "no types selected" and should return zero rows. The Thrift path was leaking rows because the post-server filter atMetadataResultSetBuilder.getTablesResultis guarded bytableTypes.length > 0, which short-circuits the filter for empty arrays.hive_metastoreobjects haveTABLE_TYPE=""from the Thrift server. The client normalizes""→"TABLE", and with the broken filter guard those rows survived even fortypes=[].DatabricksMetadataQueryClient.java:128-131) in the ThriftlistTables— short-circuit to an empty result set at the top of the method whentableTypesis non-null and length 0. The server is never queried.Test plan
testListTablesWithEmptyTypesReturnsEmptyWithoutServerCall— asserts zero rows AND thatthriftAccessor.getThriftResponseis never invokedtestListTables(non-empty types) still passes — 46/46 inDatabricksThriftServiceClientTestgetTables(null, null, null, [])on Thrift returned 2hive_metastore.default.trim_repro*rows while SEA returned 0; after fix, both return 0This pull request and its description were written by Isaac.