Skip to content

query tags integration #663

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

sreekanth-db
Copy link

@sreekanth-db sreekanth-db commented Aug 5, 2025

What type of PR is this?

  • Refactor
  • Feature
  • Bug Fix
  • Other

Description

This PR adds Query Tags support to the Python SQL Connector. Query Tags allow users to attach key-value pairs to SQL executions that appear in the system.query.history table.

Changes Made:

  1. Created Example File (examples/query_tags_example.py):

    • New file demonstrating Query Tags usage with session configuration
  2. Enhanced Integration Test (tests/e2e/test_driver.py):

    • Modified test_ssp_passthrough() to include Query Tags in session configuration
  3. Added Unit Test (tests/unit/test_session.py):

    • Created test_query_tags_configuration_passthrough() test
    • Verifies Query Tags are properly passed through to the backend

Implementation Details:

  • No Code Changes Required: The existing python connector interface supports the query tags through session_configuration parameter
import databricks.sql

connection = databricks.sql.connect(
    server_hostname='host',
    http_path='/sql/1.0/warehouses/xxx',
    access_token='token',
    session_configuration={
        'QUERY_TAGS': 'team:engineering,test:query-tags',
        'ansi_mode': False
    }
)

How is this tested?

  • Unit tests
  • E2E Tests
  • Manually
  • N/A

Testing Details:

Unit Tests:

  • test_query_tags_configuration_passthrough() - Verifies Query Tags flow through connection layers
  • All existing tests still pass

E2E Tests:

  • Enhanced test_ssp_passthrough() to include Query Tags

Manual Testing:

  • Ran examples/query_tags_example.py with real backend connection
  • Verified Query Tags are accepted and queries execute successfully

Related Tickets & Documents

Signed-off-by: Sreekanth Vadigi <sreekanth.vadigi@databricks.com>
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