snowflake.snowpark.Session.update_query_tag

Session.update_query_tag(tag: dict) None[source]

Updates a query tag that is a json encoded string. Throws an exception if the sessions current query tag is not a valid json string.

Parameters:

tag – The dict that provides updates to the current query tag dict.

Note

Assigning a value via session.query_tag will remove any current query tag state.

Example::
>>> session.query_tag = '{"key1": "value1"}'
>>> session.update_query_tag({"key2": "value2"})
>>> print(session.query_tag)
{"key1": "value1", "key2": "value2"}
Copy
Example::
>>> session.sql("ALTER SESSION SET QUERY_TAG = '{\"key1\": \"value1\"}'").collect()
[Row(status='Statement executed successfully.')]
>>> session.update_query_tag({"key2": "value2"})
>>> print(session.query_tag)
{"key1": "value1", "key2": "value2"}
Copy
Example::
>>> session.query_tag = ""
>>> session.update_query_tag({"key1": "value1"})
>>> print(session.query_tag)
{"key1": "value1"}
Copy