forked from dbt-labs/dbt-core
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feature/drop relation/ct 2581 (dbt-labs#7626)
* changie * move drop_relation macros into their own file, add scenarios for table, view, and materialized view
- Loading branch information
1 parent
8f998c2
commit 47e7b1c
Showing
3 changed files
with
51 additions
and
10 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,7 @@ | ||
kind: Features | ||
body: Update drop_relation macro to allow for configuration of drop statement separately | ||
from object name | ||
time: 2023-05-15T12:23:04.177141-04:00 | ||
custom: | ||
Author: mikealfare | ||
Issue: "7625" |
44 changes: 44 additions & 0 deletions
44
core/dbt/include/global_project/macros/adapters/drop_relation.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,44 @@ | ||
{% macro drop_relation(relation) -%} | ||
{{ return(adapter.dispatch('drop_relation', 'dbt')(relation)) }} | ||
{% endmacro %} | ||
|
||
{% macro default__drop_relation(relation) -%} | ||
{% call statement('drop_relation', auto_begin=False) -%} | ||
{%- if relation.is_table -%} | ||
{{- drop_table(relation) -}} | ||
{%- elif relation.is_view -%} | ||
{{- drop_view(relation) -}} | ||
{%- elif relation.is_materialized_view -%} | ||
{{- drop_materialized_view(relation) -}} | ||
{%- else -%} | ||
drop {{ relation.type }} if exists {{ relation }} cascade | ||
{%- endif -%} | ||
{%- endcall %} | ||
{% endmacro %} | ||
|
||
|
||
{% macro drop_table(relation) -%} | ||
{{ return(adapter.dispatch('drop_table', 'dbt')(relation)) }} | ||
{%- endmacro %} | ||
|
||
{% macro default__drop_table(relation) -%} | ||
drop table if exists {{ relation }} cascade | ||
{%- endmacro %} | ||
|
||
|
||
{% macro drop_view(relation) -%} | ||
{{ return(adapter.dispatch('drop_view', 'dbt')(relation)) }} | ||
{%- endmacro %} | ||
|
||
{% macro default__drop_view(relation) -%} | ||
drop view if exists {{ relation }} cascade | ||
{%- endmacro %} | ||
|
||
|
||
{% macro drop_materialized_view(relation) -%} | ||
{{ return(adapter.dispatch('drop_materialized_view', 'dbt')(relation)) }} | ||
{%- endmacro %} | ||
|
||
{% macro default__drop_materialized_view(relation) -%} | ||
drop materialized view if exists {{ relation }} cascade | ||
{%- 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