Snowflake Query Tags
urn:js:virtue:aspire:proposal:7.1
TL;DR
Query Tags in Snowflake MUST conform to the Snowflake Query Tag Schema.
Rational
Query Tags (QUERY_TAG) in Snowflake, set using ALTER SESSION SET QUERY_TAG='' MUST conform to the Snowflake Query Tag Schema Snowflake Query Tag Schema. Tags MUST NOT not be used that don’t conform to the schema.
Background
Snowflake provides the ability to apply a string in the ‘QUERY_TAG’ column to all queries executed within a Snowflake session. By formatting this string as a JSON blob, it is possible to more easily analyse the Snowflake Query History.
Benefits
- A common format for the QUERY_TAG allows it to be easily processed and identified. Where different JSON schemas are utilised processing of the column becomes more difficult.
- Queries issued in different session can be easily linked together to help with debugging e.g.
select CHECK_JSON(query_tag) as json_error, parse_json(query_tag):correlation_id::string as correlation_id, * from snowflake.account_usage.query_history where (query_tag != '') and (json_error is null) and (user_name = 'USER_TO_FILTER_ON') and (correlation_id = '7b3128bd-8d89-d1e5-174a-469634a64002') ; - Easy to determine whether teams are conforming to the standard by validating QUERY_TAG column entries against the schema.
Impact / Downsides
- Teams already using the QUERY_TAG feature will need to alter their code to conform to the new standard.
- Few users are currently using the QUERY_TAG field.
- It is not possible to prevent users from apply invalid tags, it is only possible to monitor for compliance and engage with those that do not comply.
Implications
None.