Add UseQueryForMetadata connection property for Thrift metadata operations#1242
Open
gopalldb wants to merge 1 commit intodatabricks:mainfrom
Open
Add UseQueryForMetadata connection property for Thrift metadata operations#1242gopalldb wants to merge 1 commit intodatabricks:mainfrom
gopalldb wants to merge 1 commit intodatabricks:mainfrom
Conversation
…dataSdkClient Add opt-in connection property `UseQueryForMetadata` that makes the Thrift path use SQL SHOW commands (via DatabricksMetadataQueryClient) instead of native Thrift RPCs for metadata operations. This fixes incorrect wildcard matching where `_` was treated as a single-character wildcard in Thrift metadata filters. Also rename DatabricksMetadataSdkClient to DatabricksMetadataQueryClient since it is now used by both SEA and Thrift paths. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> Signed-off-by: Gopal Lal <gopal.lal@databricks.com>
|
What is the performance implication here, with this change now you will get the schemas, tables, columns and more using compute resources would the latency depends on the utilization of the cluster and have you ran any benchmarks to see the difference on latency ? |
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
UseQueryForMetadatathat makes the Thrift path use SQL SHOW commands (viaDatabricksMetadataQueryClient) instead of native Thrift RPCs for metadata operationsDatabricksMetadataSdkClient→DatabricksMetadataQueryClientand internal fieldsdkClient→queryExecutionClientsince the class now serves both SEA and Thrift pathsProblem
Thrift metadata operations (
GetTables,GetSchemas,GetColumns, etc.) pass filter patterns directly to the server, which treats_as a single-character wildcard. This causes incorrect results — e.g., querying for cataloga_balso returnsaxb,a1b, etc.The SEA metadata path already solved this by using SQL SHOW commands with
LIKEpatterns (viaCommandBuilder+WildcardUtil), which handle_correctly.Solution
When
UseQueryForMetadata=1and the client type is THRIFT,DatabricksSessioncreates aDatabricksMetadataQueryClientwrapping the ThriftIDatabricksClient. This reuses the entire SEA metadata implementation — no code duplication needed — becauseDatabricksMetadataQueryClientonly callsexecuteStatement()andgetConnectionContext()on the underlying client, both of whichDatabricksThriftServiceClientalready implements.How it works
DatabricksSession.getDatabricksMetadataClient():UseQueryForMetadata=0(default): returns the Thrift client cast toIDatabricksMetadataClient(unchanged behavior)UseQueryForMetadata=1: returns aDatabricksMetadataQueryClientwrapping the Thrift client, which executes SHOW SQL commands for metadataDatabricksMetadataQueryClientas beforeThe feature is also correctly wired in all SEA→Thrift fallback paths (temporary redirect and rate limit).
Changes
DatabricksJdbcUrlParams.javaUSE_QUERY_FOR_METADATAenum constantIDatabricksConnectionContext.javauseQueryForMetadata()interface methodDatabricksConnectionContext.javauseQueryForMetadata()accessorDatabricksSession.javaDatabricksMetadataQueryClientfor Thrift when enabled; updategetDatabricksMetadataClient()dispatch; handle SEA→Thrift fallback pathsDatabricksMetadataSdkClient.java→DatabricksMetadataQueryClient.javasdkClientfield →queryExecutionClientDatabricksSessionTest.javaDatabricksMetadataSdkClientTest.java→DatabricksMetadataQueryClientTest.javaNEXT_CHANGELOG.mdBackward Compatibility
UseQueryForMetadata=0by default — existing Thrift behavior is completely unchangedEnableShowCommandForGetFunctions: that property continues to work separatelyDatabricksMetadataQueryClientis still used for SEA as beforeTest plan
DatabricksSessionTest— 16/16 pass (includes 2 new tests verifying dispatch withUseQueryForMetadata=1and default)DatabricksMetadataQueryClientTest— 44/44 pass (all existing metadata tests pass with renamed class)mvn spotless:check— cleanmvn clean install -DskipTests— builds successfully🤖 Generated with Claude Code