Add statement-level query_tags support for SEA backend#754
Merged
sreekanth-db merged 2 commits intomainfrom Mar 16, 2026
Merged
Add statement-level query_tags support for SEA backend#754sreekanth-db merged 2 commits intomainfrom
sreekanth-db merged 2 commits intomainfrom
Conversation
Signed-off-by: Sreekanth Vadigi <sreekanth.vadigi@databricks.com>
Signed-off-by: Sreekanth Vadigi <sreekanth.vadigi@databricks.com>
gopalldb
approved these changes
Mar 16, 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
The
query_tagsfeature was previously implemented only for the Thrift backend. Connection-level query tags (viasession_configuration["QUERY_TAGS"]) already worked for SEA since it goes through_filter_session_configuration. This PR adds the missing statement-level (per-execute) query tags support for the SEA backend.Root cause
SeaDatabricksClient.execute_command()accepted thequery_tagsparameter but had a# TODOcomment and silently ignored it — the tags were never included in theExecuteStatementRequest.Wire format
The SEA REST API expects
query_tagsas an array of{key, value}objects, unlike Thrift which uses a serialized string inconfOverlay:Nonevalues are passed through as-is — server handles them as key-only tagsNonedict omits the field entirely from the request{key, value}JSON format handles special characters natively (unlike the serialized string format used in Thrift/session path)Changes
src/databricks/sql/backend/sea/models/requests.py: Addquery_tagsfield toExecuteStatementRequestdataclass; serialize to[{key, value}]array into_dict()src/databricks/sql/backend/sea/backend.py: Passquery_tagstoExecuteStatementRequestconstructor; remove TODO commentTests
Unit tests added (
tests/unit/test_sea_backend.py)test_execute_command_query_tags_string_values— string values serialized correctly to[{key, value}]test_execute_command_query_tags_none_value—Nonevalues passed through as{"key": k, "value": None}test_execute_command_no_query_tags_omitted— field absent whenquery_tags=Nonetest_execute_command_empty_query_tags_omitted— field absent whenquery_tags={}test_execute_command_async_query_tags— tags included in async (execute_async) pathCI checks verified locally
E2E test
Ran
examples/query_tags_example.pywithuse_sea=Trueagainst a live Databricks SQL warehouse. All 4 examples passed — connection-level tags, per-query tags (includingNonevalues and special characters), async execution, andexecutemany. Verified tags stored correctly in query history UI including special characters (colons, commas, backslashes) — no escaping needed for the JSON{key, value}format.