Seemore supports dbt core by using custom tags for classifying data assets that run through DBT core.
In order to integrate you would need to add the following tags package - .
In order to add more informative metadata such as data orchestration tools that execute the DBT Queries .
Quickstart
Add this package to your packages.yml
file, then install it with dbt deps
.
Copy packages:
- package: get-select/dbt_snowflake_query_tags
version: [">=2.0.0", "<3.0.0"]
Option 1: If running dbt >= 1.2, simply configure the dispatch search order in dbt_project.yml
.
Copy dispatch:
- macro_namespace: dbt
search_order:
- <YOUR_PROJECT_NAME>
- dbt_snowflake_query_tags
- dbt
Option 2: If running dbt < 1.2, create a folder named macros
in your dbt project's top level directory (if it doesn't exist). Inside, make a new file called query_tags.sql
with the following content:
Copy {% macro set_query_tag() -%}
{% do return(dbt_snowflake_query_tags.set_query_tag()) %}
{% endmacro %}
{% macro unset_query_tag(original_query_tag) -%}
{% do return(dbt_snowflake_query_tags.unset_query_tag(original_query_tag)) %}
{% endmacro %}
To configure the query comments, add the following config to dbt_project.yml
.
Copy query-comment:
comment: '{{ dbt_snowflake_query_tags.get_query_comment(node) }}'
append: true # Snowflake removes prefixed comments.
That's it! All dbt-issued queries will now be tagged.
Once the dbt package to automatically tag dbt-issued queries with informative metadata has been added you can add more informative information such as Orchestration tools used to execute DBT queries.
Airflow Example
Copy query-comment:
comment: >
{{ dbt_snowflake_query_tags.get_query_comment(
node,
extra={
'workflow_id': env_var('AIRFLOW_CTX_DAG_ID', 'default_dag_id'),
'job_id': env_var('AIRFLOW_CTX_TASK_ID', 'default_taks_id'),
'scheduler': 'airflow'
}
) }}
append: true # Snowflake removes prefixed comments.
Github Actions
Copy query-comment:
comment: >
{{ dbt_snowflake_query_tags.get_query_comment(
node,
extra={
'workflow_id': env_var('GITHUB_WORKFLOW', 'default_dag_id'),
'job_id': env_var('GITHUB_JOB', 'default_taks_id'),
'scheduler': 'github_actions'
}
) }}
append: true # Snowflake removes prefixed comments.
Gitlab
Copy query-comment:
comment: >
{{ dbt_snowflake_query_tags.get_query_comment(
node,
extra={
'workflow_id': env_var('CI_PIPELINE_ID', 'default_dag_id'),
'job_id': env_var('CI_JOB_NAME', 'default_taks_id'),
'scheduler': 'gitlab'
}
) }}
append: true # Snowflake removes prefixed comments.
Good luck!