Skip to content

Commit 1643814

Browse files
authored
Include ephemeral models when dropping orphaned relations (#259) (#260)
* Include ephemeral models when dropping orphaned relations When checking for orphaned relations to drop, include ephemeral models so potential existing objects are dropped. The edge case is when a model was previously materialized as a table or view and then later changed to ephemeral, the old object never gets cleaned up and remains in the state it was last updated. * Retrigger CI --------- Authored-by: Eugene Kim
1 parent 22c6cb3 commit 1643814

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

transform/macros/tooling/ci-cd/drop_orphaned_relations.sql

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,12 @@
1919
{%- set database_name = node.database.upper() -%}
2020
{%- set schema_name = node.schema.upper() -%}
2121
{%- set table_name = node.alias if node.alias else node.name -%}
22+
{%- set materialized = node.config.materialized | default(node.materialized) -%}
23+
24+
-- Skip ephemeral models so old physical relations get cleaned up
25+
{%- if materialized == 'ephemeral' -%}
26+
{%- continue -%}
27+
{%- endif -%}
2228

2329
-- Add db name if it does not exist in the dict
2430
{%- if not database_name in current_model_locations -%}

0 commit comments

Comments
 (0)