Skip to content
This repository was archived by the owner on Mar 6, 2026. It is now read-only.
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 21 additions & 3 deletions macros/query_tags.sql
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,32 @@
{% endfor %}
{% endif %}

{% set project_tag = model.config.get('query_tag', {}) %}
{% set model_tag = config.get('query_tag', {}) %}

{# Start with any model-configured dict #}
{% set query_tag = config.get('query_tag', default={}) %}

{% if query_tag is not mapping %}
{% do log("dbt-snowflake-query-tags warning: the query_tag config value of '{}' is not a mapping type, so is being ignored. If you'd like to add additional query tag information, use a mapping type instead, or remove it to avoid this message.".format(query_tag), True) %}
{% set query_tag = {} %} {# If the user has set the query tag config as a non mapping type, start fresh #}
{% if not project_tag is mapping %}
{% do log("dbt-snowflake-query-tags warning: the query_tag config value of '{}' is not a mapping type, so is being ignored. If you'd like to add additional query tag information, use a mapping type instead, or remove it to avoid this message.".format(query_tag), True) %}

{% set project_tag = {} %}
{% endif %}

{% if not model_tag is mapping %}
{% do log("dbt-snowflake-query-tags warning: the query_tag config value of '{}' is not a mapping type, so is being ignored. If you'd like to add additional query tag information, use a mapping type instead, or remove it to avoid this message.".format(query_tag), True) %}

{% set model_tag = {} %}
{% endif %}

{# Manual merge: model-level overrides project-level #}
{% set query_tag = project_tag.copy() %}
{% for k, v in model_tag.items() %}
{% do query_tag.update({k: v}) %}
{% endfor %}


{# --- Step 4: Add session/original/env_var/extra tags (keep package behavior) --- #}
{% do query_tag.update(original_query_tag_parsed) %}
{% do query_tag.update(env_var_query_tags) %}
{% do query_tag.update(extra) %}
Expand Down
Loading