Skip to content
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

ct-2587: adds query tag macros and updates table materialization #7770

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 1 commit
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
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,19 @@
{% endif %}
{% do return(config_store_failures) %}
{% endmacro %}

{% macro set_query_tag() %}
{{ return(adapter.dispatch('set_query_tag', 'dbt')()) }}
{% endmacro %}

{% macro unset_query_tag(original_query_tag) %}
{{ return(adapter.dispatch('unset_query_tag', 'dbt')(original_query_tag)) }}
{% endmacro %}

{% macro default__set_query_tag() %}
{{ log("Couldn't set query tag, current adapter does not have get_current_query_tag() macro implemented.",info=True) }}
{% endmacro%}

{% macro default__unset_query_tag() %}
{{ log("Couldn't unset query tag, current adapter does not have get_current_query_tag() macro implemented.",info=True) }}
{% endmacro%}
Comment on lines +31 to +37
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is fine during development, but I think we'd want this to be an actual noop by default (= just return an empty string). No need to clutter the logs for Postgres users with a bunch of these messages.

Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{% materialization table, default %}

{% set original_query_tag = set_query_tag() %}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We'll want this everywhere that dbt-snowflake currently has it implemented:

  • table
  • view
  • incremental
  • seed
  • snapshot
  • test
  • MV / dynamic table

Then we can totally delete & remove the Snowflake-specific implementations of test, snapshot, and seed — which only exist to support setting/unsetting query tags.

{%- set existing_relation = load_cached_relation(this) -%}
{%- set target_relation = this.incorporate(type='table') %}
{%- set intermediate_relation = make_intermediate_relation(target_relation) -%}
Expand Down Expand Up @@ -55,5 +56,7 @@

{{ run_hooks(post_hooks, inside_transaction=False) }}

{% do unset_query_tag(original_query_tag) %}

{{ return({'relations': [target_relation]}) }}
{% endmaterialization %}