From c1e8f86ed8620f94ac92e3a1661581947c98c29a Mon Sep 17 00:00:00 2001 From: Claus Herther Date: Mon, 25 Mar 2019 09:27:41 -0700 Subject: [PATCH 1/2] Upgrades insert_by_period materialization to dbt 0.13.0 --- dbt_project.yml | 2 ++ .../materializations/insert_by_period_materialization.sql | 7 +++---- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/dbt_project.yml b/dbt_project.yml index 1ef4029f..88c062dc 100644 --- a/dbt_project.yml +++ b/dbt_project.yml @@ -1,6 +1,8 @@ name: 'dbt_utils' version: '0.1.0' +require-dbt-version: "0.13.0" + target-path: "target" clean-targets: ["target", "dbt_modules"] macro-paths: ["macros"] diff --git a/macros/materializations/insert_by_period_materialization.sql b/macros/materializations/insert_by_period_materialization.sql index ceb118b6..618ff063 100644 --- a/macros/materializations/insert_by_period_materialization.sql +++ b/macros/materializations/insert_by_period_materialization.sql @@ -57,7 +57,7 @@ {%- set identifier = model['name'] -%} - {%- set old_relation = adapter.get_relation(schema=schema, identifier=identifier) -%} + {%- set old_relation = adapter.get_relation(database=database, schema=schema, identifier=identifier) -%} {%- set target_relation = api.Relation.create(identifier=identifier, schema=schema, type='table') -%} {%- set non_destructive_mode = (flags.NON_DESTRUCTIVE == True) -%} @@ -108,7 +108,7 @@ {%- set stop_timestamp = load_result('period_boundaries')['data'][0][1] | string -%} {%- set num_periods = load_result('period_boundaries')['data'][0][2] | int -%} - {% set target_columns = adapter.get_columns_in_table(schema, identifier) %} + {% set target_columns = adapter.get_columns_in_relation(target_relation) %} {%- set target_cols_csv = target_columns | map(attribute='quoted') | join(', ') -%} {%- set loop_vars = {'sum_rows_inserted': 0} -%} @@ -132,8 +132,7 @@ {%- endcall %} {{adapter.expand_target_column_types(temp_table=tmp_identifier, - to_schema=schema, - to_table=identifier)}} + to_relation=target_relation)}} {%- set name = 'main-' ~ i -%} {% call statement(name, fetch_result=True) -%} insert into {{target_relation}} ({{target_cols_csv}}) From 66de569c5730c189c9355dbca35ce324be6498f4 Mon Sep 17 00:00:00 2001 From: Claus Herther Date: Mon, 25 Mar 2019 10:00:49 -0700 Subject: [PATCH 2/2] Updates dbt version requirement to >=0.13.0 --- dbt_project.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dbt_project.yml b/dbt_project.yml index 88c062dc..7527aacd 100644 --- a/dbt_project.yml +++ b/dbt_project.yml @@ -1,7 +1,7 @@ name: 'dbt_utils' version: '0.1.0' -require-dbt-version: "0.13.0" +require-dbt-version: ">=0.13.0" target-path: "target" clean-targets: ["target", "dbt_modules"]