Skip to content

Fix getTables(types=[]) returning rows in Thrift mode#1451

Merged
sreekanth-db merged 1 commit into
mainfrom
fix/getTables-empty-types
May 18, 2026
Merged

Fix getTables(types=[]) returning rows in Thrift mode#1451
sreekanth-db merged 1 commit into
mainfrom
fix/getTables-empty-types

Conversation

@sreekanth-db
Copy link
Copy Markdown
Collaborator

Summary

  • Per JDBC spec, DatabaseMetaData.getTables(_, _, _, new String[0]) (empty types array) means "no types selected" and should return zero rows. The Thrift path was leaking rows because the post-server filter at MetadataResultSetBuilder.getTablesResult is guarded by tableTypes.length > 0, which short-circuits the filter for empty arrays.
  • Symptom: legacy hive_metastore objects have TABLE_TYPE="" from the Thrift server. The client normalizes """TABLE", and with the broken filter guard those rows survived even for types=[].
  • Fix: mirror SEA's existing guard (DatabricksMetadataQueryClient.java:128-131) in the Thrift listTables — short-circuit to an empty result set at the top of the method when tableTypes is non-null and length 0. The server is never queried.

Test plan

  • Added testListTablesWithEmptyTypesReturnsEmptyWithoutServerCall — asserts zero rows AND that thriftAccessor.getThriftResponse is never invoked
  • Existing testListTables (non-empty types) still passes — 46/46 in DatabricksThriftServiceClientTest
  • Verified end-to-end against a real workspace: before fix, getTables(null, null, null, []) on Thrift returned 2 hive_metastore.default.trim_repro* rows while SEA returned 0; after fix, both return 0

This pull request and its description were written by Isaac.

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>
@sreekanth-db sreekanth-db enabled auto-merge (squash) May 18, 2026 09:41
@sreekanth-db sreekanth-db merged commit 727db4c into main May 18, 2026
16 checks passed
@sreekanth-db sreekanth-db deleted the fix/getTables-empty-types branch May 18, 2026 10:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants