Skip to content

Commit

Permalink
Feature/support query tags in tests (#210)
Browse files Browse the repository at this point in the history
* initial test materialization with query tagging

* set adapter to snowflake

* move over core materialization code for testing

* add query tagging macros

* revise with jtcohen's version

* add validation on query tags for tests

* add changelog entry

* update changelog again

* fix linting issue & update changelog with PR

* update changelog using changie
  • Loading branch information
matt-winkler authored Aug 22, 2022
1 parent 3265155 commit 25a7d22
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 0 deletions.
7 changes: 7 additions & 0 deletions .changes/unreleased/Features-20220815-233505.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
kind: Features
body: Support query tags in dbt tests using the `+query_tag` config in `dbt_project.yml`
time: 2022-08-15T23:35:05.967484-06:00
custom:
Author: matt-winkler
Issue: "211"
PR: "210"
8 changes: 8 additions & 0 deletions dbt/include/snowflake/macros/materializations/test.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{%- materialization test, adapter='snowflake' -%}

{% set original_query_tag = set_query_tag() %}
{% set relations = materialization_test_default() %}
{% do unset_query_tag(original_query_tag) %}
{{ return(relations) }}

{%- endmaterialization -%}
8 changes: 8 additions & 0 deletions tests/integration/query_tag_tests/models/models.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
version: 2

models:
- name: view_model_query_tag
columns:
- name: id
tests:
- unique
6 changes: 6 additions & 0 deletions tests/integration/query_tag_tests/test_query_tags.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,12 @@ def project_config(self):
'post-hook': '{{ check_query_tag() }}'
},
},
'tests': {
'test': {
'query_tag': self.prefix,
'post-hook': '{{ check_query_tag() }}'
}
},
}

def build_all_with_query_tags(self):
Expand Down

0 comments on commit 25a7d22

Please sign in to comment.