-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
33 changed files
with
365 additions
and
48 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
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
44 changes: 40 additions & 4 deletions
44
core/dbt/include/global_project/macros/materializations/test.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 |
---|---|---|
@@ -1,10 +1,46 @@ | ||
{%- materialization test, default -%} | ||
|
||
{% set relations = [] %} | ||
|
||
{% if should_store_failures() %} | ||
|
||
{% set identifier = model['alias'] %} | ||
{% set old_relation = adapter.get_relation(database=database, schema=schema, identifier=identifier) %} | ||
{% set target_relation = api.Relation.create( | ||
identifier=identifier, schema=schema, database=database, type='table') -%} %} | ||
|
||
{% if old_relation %} | ||
{% do adapter.drop_relation(old_relation) %} | ||
{% endif %} | ||
|
||
{% call statement(auto_begin=True) %} | ||
{{ create_table_as(False, target_relation, sql) }} | ||
{% endcall %} | ||
|
||
{% do relations.append(target_relation) %} | ||
|
||
{% set main_sql %} | ||
select count(*) as validation_errors | ||
from {{ target_relation }} | ||
{% endset %} | ||
|
||
{{ adapter.commit() }} | ||
|
||
{% else %} | ||
|
||
{% set main_sql %} | ||
select count(*) as validation_errors | ||
from ( | ||
{{ sql }} | ||
) _dbt_internal_test | ||
{% endset %} | ||
|
||
{% endif %} | ||
|
||
{% call statement('main', fetch_result=True) -%} | ||
select count(*) as validation_errors | ||
from ( | ||
{{ sql }} | ||
) _dbt_internal_test | ||
{{ main_sql }} | ||
{%- endcall %} | ||
|
||
{{ return({'relations': 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
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
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
Oops, something went wrong.