-
Notifications
You must be signed in to change notification settings - Fork 117
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
base: main
Are you sure you want to change the base?
Conversation
Signed-off-by: Sreekanth Vadigi <sreekanth.vadigi@databricks.com>
Signed-off-by: Sreekanth Vadigi <sreekanth.vadigi@databricks.com>
d61e96a
to
cf7df8d
Compare
for enable_ansi in (True, False): | ||
with self.cursor( | ||
{"session_configuration": {"ansi_mode": enable_ansi}} | ||
{"session_configuration": {"ansi_mode": enable_ansi, "QUERY_TAGS": "team:marketing,dashboard:abc123,driver:python"}, **extra_params} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we add a test with invalid query param format & see if we are getting the required error?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the backend design docs, it is mentioned that invalid query tags will be ignored without raising error so that actual query execution won't result in failure. Tested manually in local by passing invalid/non-parsable query tags - backend doesn't throw error
} | ||
result = _filter_session_configuration(case_insensitive_config) | ||
expected_case_result = { | ||
"ansi_mode": "false", | ||
"statement_timeout": "7200", | ||
"timezone": "America/New_York", | ||
"query_tags": "team:marketing,test:case-insensitive", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similarly two scenarios we can add here
- Not passing the query tags config param
- Passing non parsable query tags -> "team:marketing,test"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
-
_filter_session_configuration
method loops through provided session config fields and filters out invalid params, so separate unit test for not passing query tags would be an overkill. For e2e tests, we already have few tests in which we don't pass query tags as part of session config. -
We don't do any parsing of query tags in the driver and we send the user provided value as is to the backend. As mentioned in the other comment, backend would ignore the non parsable query tags without raising the error
What type of PR is this?
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:
Created Example File (
examples/query_tags_example.py
):Enhanced Integration Test (
tests/e2e/test_driver.py
):test_ssp_passthrough()
to include Query Tags in session configurationEnhanced Unit Tests (
tests/unit/test_session.py
):test_configuration_passthrough()
test to verify query tags are properly passed through to the thrift backendtest_session_management()
to include query tags in session configuration to ensure query tags work correctly in SEA backendImplementation Details:
Added Query Tags Support in SEA flow (
src/databricks/sql/backend/sea/utils/constants.py
):"QUERY_TAGS": ""
toALLOWED_SESSION_CONF_TO_DEFAULT_VALUES_MAP
to enable query tags support in the SEA (Statement Execution API) backend flowUsage example:
How is this tested?
Testing Details:
Unit Tests:
test_configuration_passthrough()
- Verifies Query Tags flow in thrift modetest_session_management()
- Verifies Query Tags flow in SEA modeE2E Tests:
test_ssp_passthrough()
to include Query Tags in both thirft and SEA modesManual Testing:
examples/query_tags_example.py
with real backend connectionRelated Tickets & Documents