-
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.
ADAP-869: Support atomic replace in replace macro (#8539)
* move config changes into alter.sql in alignment with other adapters * move shared relations macros to relations root * move single models files to models root * add table to replace * move create file into relation directory * implement replace for postgres * move column specific macros into column directory * add unit test for can_be_replaced * update renameable_relations and replaceable_relations to frozensets to set defaults * fixed tests for new defaults
- Loading branch information
1 parent
6c6f245
commit 9716690
Showing
23 changed files
with
177 additions
and
78 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: Features | ||
body: Support atomic replace in the global replace macro | ||
time: 2023-08-31T20:48:04.098933-04:00 | ||
custom: | ||
Author: mikealfare | ||
Issue: "8539" |
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
File renamed without changes.
23 changes: 0 additions & 23 deletions
23
...materializations/models/materialized_view/get_materialized_view_configuration_changes.sql
This file was deleted.
Oops, something went wrong.
File renamed without changes.
File renamed without changes.
8 changes: 0 additions & 8 deletions
8
core/dbt/include/global_project/macros/materializations/models/view/helpers.sql
This file was deleted.
Oops, something went wrong.
File renamed without changes.
14 changes: 0 additions & 14 deletions
14
core/dbt/include/global_project/macros/relations/materialized_view/_replace.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
10 changes: 10 additions & 0 deletions
10
core/dbt/include/global_project/macros/relations/materialized_view/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,10 @@ | ||
{% macro get_replace_materialized_view_sql(relation, sql) %} | ||
{{- adapter.dispatch('get_replace_materialized_view_sql', 'dbt')(relation, sql) -}} | ||
{% endmacro %} | ||
|
||
|
||
{% macro default__get_replace_materialized_view_sql(relation, sql) %} | ||
{{ exceptions.raise_compiler_error( | ||
"`get_replace_materialized_view_sql` has not been implemented for this adapter." | ||
) }} | ||
{% 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
File renamed without changes.
10 changes: 10 additions & 0 deletions
10
core/dbt/include/global_project/macros/relations/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,10 @@ | ||
{% macro get_replace_table_sql(relation, sql) %} | ||
{{- adapter.dispatch('get_replace_table_sql', 'dbt')(relation, sql) -}} | ||
{% endmacro %} | ||
|
||
|
||
{% macro default__get_replace_table_sql(relation, sql) %} | ||
{{ exceptions.raise_compiler_error( | ||
"`get_replace_table_sql` has not been implemented for this adapter." | ||
) }} | ||
{% endmacro %} |
File renamed without changes.
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
5 changes: 0 additions & 5 deletions
5
plugins/postgres/dbt/include/postgres/macros/materializations/materialized_view.sql
This file was deleted.
Oops, something went wrong.
16 changes: 0 additions & 16 deletions
16
plugins/postgres/dbt/include/postgres/macros/relations/materialized_view/_replace.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
17 changes: 17 additions & 0 deletions
17
plugins/postgres/dbt/include/postgres/macros/relations/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,17 @@ | ||
{% macro postgres__get_replace_table_sql(relation, sql) -%} | ||
|
||
{%- set sql_header = config.get('sql_header', none) -%} | ||
{{ sql_header if sql_header is not none }} | ||
|
||
create or replace table {{ relation }} | ||
{% set contract_config = config.get('contract') %} | ||
{% if contract_config.enforced %} | ||
{{ get_assert_columns_equivalent(sql) }} | ||
{{ get_table_columns_and_constraints() }} | ||
{%- set sql = get_select_subquery(sql) %} | ||
{% endif %} | ||
as ( | ||
{{ sql }} | ||
); | ||
|
||
{%- endmacro %} |
15 changes: 15 additions & 0 deletions
15
plugins/postgres/dbt/include/postgres/macros/relations/view/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,15 @@ | ||
{% macro postgres__get_replace_view_sql(relation, sql) -%} | ||
|
||
{%- set sql_header = config.get('sql_header', none) -%} | ||
{{ sql_header if sql_header is not none }} | ||
|
||
create or replace view {{ relation }} | ||
{% set contract_config = config.get('contract') %} | ||
{% if contract_config.enforced %} | ||
{{ get_assert_columns_equivalent(sql) }} | ||
{%- endif %} | ||
as ( | ||
{{ sql }} | ||
); | ||
|
||
{%- 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