Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Slack alerts for failed nightly tests (#50) * Fix: Support individual query tag configuration for Seeds and Snapshots (#48) * Add Query Tag for Seed * Add Query Tag for Snapshots * Add Changelog for #48 * Add Snapshot with Query Tag test * Add Seed with Query Tag test * Update connections.py (#49) * Update connections.py Resolves issues when the Snowflake OCSP server is not reachable and the dbt user would like to run commands without checking the OCSP server. OCSP failures/inaccessibilitiy are possible due to network routing issues or when corporate network security has exposed Snowflake (especially in privatelink) but not the OCSP server. * Update CHANGELOG.md Adding changelog information * Update CHANGELOG.md Co-authored-by: Jeremy Cohen <jtcohen6@gmail.com> * Update changelog and unit test Updated changelog and unit tests as requested. * Fix typo Co-authored-by: Jeremy Cohen <jtcohen6@gmail.com> Co-authored-by: Jeremy Cohen <jeremy@dbtlabs.com> * Add column comments to Snowflake views (#53) * Add column comments to Snowflake views * Update create_view_as macro to include column comments * Add test for column-level view comments * Add testing for column comments with non-lowercase column names * Organizing adapter macros for column persistence * Refactor query tag tests (#57) * Refactor query tag tests * Try this * Try storing failures, too * Keep trying * Try it this way * Bumping version to 1.0.0rc2 (#56) * Bumping version to 1.0.0rc2 * Update changelog Co-authored-by: Github Build Bot <buildbot@fishtownanalytics.com> Co-authored-by: Jeremy Cohen <jeremy@dbtlabs.com> Co-authored-by: Anton Huck <anthu@users.noreply.github.com> Co-authored-by: R. Joshua Huntley <JoshuaHuntley@users.noreply.github.com> Co-authored-by: Jeremy Cohen <jtcohen6@gmail.com> Co-authored-by: Jeremy Cohen <jeremy@dbtlabs.com> Co-authored-by: Spencer Taylor <85514383+spencer-taylor-workrise@users.noreply.github.com> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: Github Build Bot <buildbot@fishtownanalytics.com>
- Loading branch information
1 parent
e3769b3
commit 9e4d265
Showing
20 changed files
with
218 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
version = '1.0.0rc1' | ||
version = '1.0.0rc2' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{% materialization snapshot, adapter='snowflake' %} | ||
{% set original_query_tag = set_query_tag() %} | ||
|
||
{% set relations = materialization_snapshot_default() %} | ||
|
||
{% do unset_query_tag(original_query_tag) %} | ||
|
||
{{ return(relations) }} | ||
{% endmaterialization %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
select 1 as {{ adapter.quote("2id") }} | ||
select 1 as {{ adapter.quote("2id") }}, 2 as {{ adapter.quote("3iD") }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{% macro check_query_tag() %} | ||
|
||
{% if execute %} | ||
{% set query_tag = get_current_query_tag() %} | ||
{% if query_tag != var("query_tag") %} | ||
{{ exceptions.raise_compiler_error("Query tag not used!") }} | ||
{% endif %} | ||
{% endif %} | ||
|
||
{% endmacro %} |
3 changes: 3 additions & 0 deletions
3
tests/integration/query_tag_tests/models/incremental_model_query_tag.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{{ config(materialized = 'incremental', unique_key = 'id') }} | ||
|
||
select 1 as id |
3 changes: 3 additions & 0 deletions
3
tests/integration/query_tag_tests/models/table_model_query_tag.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{{ config(materialized = 'table') }} | ||
|
||
select 1 as id |
3 changes: 3 additions & 0 deletions
3
tests/integration/query_tag_tests/models/view_model_query_tag.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{{ config(materialized = 'view') }} | ||
|
||
select 1 as id |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
id | ||
1 |
12 changes: 12 additions & 0 deletions
12
tests/integration/query_tag_tests/snapshots/snapshot_query_tag.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{% snapshot snapshot_query_tag %} | ||
{{ | ||
config( | ||
target_database=database, | ||
target_schema=schema, | ||
unique_key='id', | ||
strategy='check', | ||
check_cols=['color'], | ||
) | ||
}} | ||
select 1 as id, 'blue' as color | ||
{% endsnapshot %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import os | ||
import csv | ||
from tests.integration.base import DBTIntegrationTest, use_profile | ||
|
||
class TestSeedWithQueryTag(DBTIntegrationTest): | ||
@property | ||
def schema(self): | ||
return "query_tag" | ||
|
||
@property | ||
def models(self): | ||
return "models" | ||
|
||
@property | ||
def project_config(self): | ||
return { | ||
'config-version': 2, | ||
'models': { | ||
'test': { | ||
'query_tag': self.prefix, | ||
'post-hook': '{{ check_query_tag() }}' | ||
}, | ||
}, | ||
'seeds': { | ||
'test': { | ||
'query_tag': self.prefix, | ||
'post-hook': '{{ check_query_tag() }}' | ||
}, | ||
}, | ||
'snapshots': { | ||
'test': { | ||
'query_tag': self.prefix, | ||
'post-hook': '{{ check_query_tag() }}' | ||
}, | ||
}, | ||
} | ||
|
||
def build_all_with_query_tags(self): | ||
self.run_dbt(['build', '--vars', '{{"query_tag": "{}"}}'.format(self.prefix)]) | ||
|
||
@use_profile('snowflake') | ||
def test__snowflake__build_tagged_twice(self): | ||
self.build_all_with_query_tags() | ||
self.build_all_with_query_tags() | ||
|
||
|
16 changes: 16 additions & 0 deletions
16
...s/integration/simple_snapshot_test/check-snapshots-query-tag-expected/check_query_tag.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
|
||
|
||
with query as ( | ||
|
||
-- check that the current value for id=1 is red | ||
select case when ( | ||
select count(*) | ||
from table(information_schema.query_history_by_user()) | ||
where QUERY_TAG = '{{ var('query_tag') }}' | ||
) > 1 then 0 else 1 end as failures | ||
|
||
) | ||
|
||
select * | ||
from query | ||
where failures = 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters