From c988805469702938674f3663840c84197442d738 Mon Sep 17 00:00:00 2001 From: Elon Gliksberg Date: Tue, 19 Sep 2023 11:59:19 +0300 Subject: [PATCH 1/2] Move sync materializations to cloud dbt project. --- .../macros/materializations/incremental.sql | 19 ------------------ .../macros/materializations/table.sql | 20 ------------------- 2 files changed, 39 deletions(-) delete mode 100644 elementary/monitor/dbt_project/macros/materializations/incremental.sql delete mode 100644 elementary/monitor/dbt_project/macros/materializations/table.sql diff --git a/elementary/monitor/dbt_project/macros/materializations/incremental.sql b/elementary/monitor/dbt_project/macros/materializations/incremental.sql deleted file mode 100644 index b83e24345..000000000 --- a/elementary/monitor/dbt_project/macros/materializations/incremental.sql +++ /dev/null @@ -1,19 +0,0 @@ -{# We override the materialization in order to achieve schema migration mode without actually transforming the data. #} -{% materialization incremental, default -%} - {% if not var("sync", false) %} - {{ return(dbt.materialization_incremental_default()) }} - {% endif %} - - {% set init_schema_sql %} - with result as ( - {{ sql }} - ) - select * from result where 1 = 0 - {% endset %} - {% do context.update({ - "sql": init_schema_sql, - "pre_hooks": [], - "post_hooks": [], - }) %} - {{ return(dbt.materialization_incremental_default()) }} -{% endmaterialization %} diff --git a/elementary/monitor/dbt_project/macros/materializations/table.sql b/elementary/monitor/dbt_project/macros/materializations/table.sql deleted file mode 100644 index fafca1bd2..000000000 --- a/elementary/monitor/dbt_project/macros/materializations/table.sql +++ /dev/null @@ -1,20 +0,0 @@ -{# We override the materialization in order to achieve schema migration mode without actually transforming the data. #} -{% materialization table, default -%} - {% if not var("sync", false) %} - {{ return(dbt.materialization_table_default()) }} - {% endif %} - - {% set init_schema_sql %} - with result as ( - {{ sql }} - ) - select * from result where 1 = 0 - {% endset %} - {% do context.update({ - "sql": init_schema_sql, - "pre_hooks": [], - "post_hooks": [], - }) %} - {# We call the incremental materialization in order to hand-off the implementation of schema changes to dbt. #} - {{ return(dbt.materialization_incremental_default()) }} -{% endmaterialization %} From e77a215eac8a790282b87c614fcd0490908112bd Mon Sep 17 00:00:00 2001 From: Elon Gliksberg Date: Tue, 19 Sep 2023 12:08:19 +0300 Subject: [PATCH 2/2] Updated 'on_schema_change'. --- elementary/monitor/dbt_project/dbt_project.yml | 7 ------- 1 file changed, 7 deletions(-) diff --git a/elementary/monitor/dbt_project/dbt_project.yml b/elementary/monitor/dbt_project/dbt_project.yml index 71a16879e..ce4e3dbe0 100644 --- a/elementary/monitor/dbt_project/dbt_project.yml +++ b/elementary/monitor/dbt_project/dbt_project.yml @@ -35,10 +35,3 @@ quoting: database: "{{ env_var('DATABASE_QUOTING', 'None') | as_native }}" schema: "{{ env_var('SCHEMA_QUOTING', 'None') | as_native }}" identifier: "{{ env_var('IDENTIFIER_QUOTING', 'None') | as_native }}" - -# In this example config, we tell dbt to build all models in the example/ directory -# as tables. These settings can be overridden in the individual model files -# using the `{{ config(...) }}` macro. -models: - # Required in order to apply table schema changes in the table materialization. - +on_schema_change: "append_new_columns"