-
Notifications
You must be signed in to change notification settings - Fork 179
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' of gist.github.com:dbt-labs/dbt-snowflake
- Loading branch information
Showing
19 changed files
with
206 additions
and
195 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
kind: "Dependencies" | ||
body: "Bump mypy from 1.5.0 to 1.5.1" | ||
time: 2023-08-17T12:16:52.00000Z | ||
custom: | ||
Author: dependabot[bot] | ||
PR: 749 |
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,6 @@ | ||
kind: "Dependencies" | ||
body: "Update tox requirement from ~=4.10 to ~=4.11" | ||
time: 2023-08-30T12:54:48.00000Z | ||
custom: | ||
Author: dependabot[bot] | ||
PR: 759 |
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,6 @@ | ||
kind: Fixes | ||
body: remove senesitive creds from dbt debug stdout | ||
time: 2023-08-28T14:38:34.380646-05:00 | ||
custom: | ||
Author: McKnight-42 | ||
Issue: "754" |
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,7 @@ | ||
kind: Under the Hood | ||
body: Restructure macros files - move relation ddl statements into separate files | ||
and directories | ||
time: 2023-08-21T23:09:21.317975-04:00 | ||
custom: | ||
Author: mikealfare | ||
Issue: "750" |
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
89 changes: 0 additions & 89 deletions
89
dbt/include/snowflake/macros/materializations/dynamic_table/ddl.sql
This file was deleted.
Oops, something went wrong.
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 @@ | ||
{% macro snowflake__drop_relation(relation) -%} | ||
{%- if relation.is_dynamic_table -%} | ||
{% call statement('drop_relation', auto_begin=False) -%} | ||
drop dynamic table if exists {{ relation }} | ||
{%- endcall %} | ||
{%- else -%} | ||
{{- default__drop_relation(relation) -}} | ||
{%- endif -%} | ||
{% endmacro %} |
5 changes: 5 additions & 0 deletions
5
dbt/include/snowflake/macros/relations/dynamic_table/_replace.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,5 @@ | ||
{% macro snowflake__get_replace_dynamic_table_as_sql(target_relation, sql, existing_relation, backup_relation, intermediate_relation) -%} | ||
{{- log('Applying REPLACE to: ' ~ target_relation) -}} | ||
{{ snowflake__get_drop_dynamic_table_sql(existing_relation) }}; | ||
{{ snowflake__get_create_dynamic_table_as_sql(target_relation, sql) }} | ||
{%- endmacro %} |
27 changes: 27 additions & 0 deletions
27
dbt/include/snowflake/macros/relations/dynamic_table/alter.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,27 @@ | ||
{% macro snowflake__get_alter_dynamic_table_as_sql( | ||
target_relation, | ||
configuration_changes, | ||
sql, | ||
existing_relation, | ||
backup_relation, | ||
intermediate_relation | ||
) -%} | ||
{{- log('Applying ALTER to: ' ~ target_relation) -}} | ||
|
||
{% if configuration_changes.requires_full_refresh %} | ||
{{- snowflake__get_replace_dynamic_table_as_sql(target_relation, sql, existing_relation, backup_relation, intermediate_relation) -}} | ||
|
||
{% else %} | ||
|
||
{%- set target_lag = configuration_changes.target_lag -%} | ||
{%- if target_lag -%}{{- log('Applying UPDATE TARGET_LAG to: ' ~ existing_relation) -}}{%- endif -%} | ||
{%- set snowflake_warehouse = configuration_changes.snowflake_warehouse -%} | ||
{%- if snowflake_warehouse -%}{{- log('Applying UPDATE WAREHOUSE to: ' ~ existing_relation) -}}{%- endif -%} | ||
|
||
alter dynamic table {{ existing_relation }} set | ||
{% if target_lag %}target_lag = '{{ target_lag.context }}'{% endif %} | ||
{% if snowflake_warehouse %}warehouse = {{ snowflake_warehouse.context }}{% endif %} | ||
|
||
{%- endif -%} | ||
|
||
{%- endmacro %} |
13 changes: 13 additions & 0 deletions
13
dbt/include/snowflake/macros/relations/dynamic_table/create.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,13 @@ | ||
{% macro snowflake__get_create_dynamic_table_as_sql(relation, sql) -%} | ||
{{- log('Applying CREATE to: ' ~ relation) -}} | ||
|
||
create or replace dynamic table {{ relation }} | ||
target_lag = '{{ config.get("target_lag") }}' | ||
warehouse = {{ config.get("snowflake_warehouse") }} | ||
as ( | ||
{{ sql }} | ||
) | ||
; | ||
{{ snowflake__refresh_dynamic_table(relation) }} | ||
|
||
{%- endmacro %} |
19 changes: 19 additions & 0 deletions
19
dbt/include/snowflake/macros/relations/dynamic_table/describe.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,19 @@ | ||
{% macro snowflake__describe_dynamic_table(relation) %} | ||
{%- set _dynamic_table_sql -%} | ||
show dynamic tables | ||
like '{{ relation.identifier }}' | ||
in schema {{ relation.database }}.{{ relation.schema }} | ||
; | ||
select | ||
"name", | ||
"schema_name", | ||
"database_name", | ||
"text", | ||
"target_lag", | ||
"warehouse" | ||
from table(result_scan(last_query_id())) | ||
{%- endset %} | ||
{% set _dynamic_table = run_query(_dynamic_table_sql) %} | ||
|
||
{% do return({'dynamic_table': _dynamic_table}) %} | ||
{% endmacro %} |
3 changes: 3 additions & 0 deletions
3
dbt/include/snowflake/macros/relations/dynamic_table/drop.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 @@ | ||
{% macro snowflake__get_drop_dynamic_table_sql(relation) %} | ||
drop dynamic table if exists {{ relation }} | ||
{% endmacro %} |
5 changes: 5 additions & 0 deletions
5
dbt/include/snowflake/macros/relations/dynamic_table/refresh.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,5 @@ | ||
{% macro snowflake__refresh_dynamic_table(relation) -%} | ||
{{- log('Applying REFRESH to: ' ~ relation) -}} | ||
|
||
alter dynamic table {{ relation }} refresh | ||
{%- endmacro %} |
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,5 @@ | ||
{% macro snowflake__rename_relation(from_relation, to_relation) -%} | ||
{% call statement('rename_relation') -%} | ||
alter table {{ from_relation }} rename to {{ to_relation }} | ||
{%- endcall %} | ||
{% endmacro %} |
Oops, something went wrong.