From 0970285956c765628cad85e03aac71f774c558e3 Mon Sep 17 00:00:00 2001 From: Drew Banin Date: Wed, 28 Aug 2019 11:30:27 -0400 Subject: [PATCH 1/2] make snapshot check strategy simpler and still correct --- .../materializations/snapshot/strategies.sql | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) diff --git a/core/dbt/include/global_project/macros/materializations/snapshot/strategies.sql b/core/dbt/include/global_project/macros/materializations/snapshot/strategies.sql index 6de9151ddff..fd7eb2b9624 100644 --- a/core/dbt/include/global_project/macros/materializations/snapshot/strategies.sql +++ b/core/dbt/include/global_project/macros/materializations/snapshot/strategies.sql @@ -107,19 +107,7 @@ ) {%- endset %} - {% if target_exists %} - {% set row_version -%} - ( - select count(*) from {{ snapshotted_rel }} - where {{ snapshotted_rel }}.dbt_unique_key = {{ primary_key }} - ) - {%- endset %} - {% set scd_id_cols = [primary_key, row_version] + (check_cols | list) %} - {% else %} - {% set scd_id_cols = [primary_key] + (check_cols | list) %} - {% endif %} - - {% set scd_id_expr = snapshot_hash_arguments(scd_id_cols) %} + {% set scd_id_expr = snapshot_hash_arguments([primary_key, updated_at]) %} {% do return({ "unique_key": primary_key, From 3437b0f2b91b1bdb361942a7f3e0f55c24989ed7 Mon Sep 17 00:00:00 2001 From: Drew Banin Date: Wed, 28 Aug 2019 14:43:21 -0400 Subject: [PATCH 2/2] Update CHANGELOG.md --- CHANGELOG.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0f8c0a16f87..1076a90daa3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -21,7 +21,7 @@ This is primarily a bugfix release which contains a few minor improvements too. - Add support for job priority on BigQuery ([#1456](https://github.com/fishtown-analytics/dbt/issues/1456), [#1673](https://github.com/fishtown-analytics/dbt/pull/1673)) ### Fixes: - - Fix for reused `check_cols` values in snapshots ([#1614](https://github.com/fishtown-analytics/dbt/pull/1614)) + - Fix for reused `check_cols` values in snapshots ([#1614](https://github.com/fishtown-analytics/dbt/pull/1614), [#1709](https://github.com/fishtown-analytics/dbt/pull/1709)) - Fix for rendering column descriptions in sources ([#1619](https://github.com/fishtown-analytics/dbt/issues/1619), [#1633](https://github.com/fishtown-analytics/dbt/pull/1633)) - Fix for `is_incremental()` returning True for models that are not materialized as incremental models ([#1249](https://github.com/fishtown-analytics/dbt/issues/1249), [#1608](https://github.com/fishtown-analytics/dbt/pull/1608)) - Fix for serialization of BigQuery results which contain nested or repeated records ([#1626](https://github.com/fishtown-analytics/dbt/issues/1626), [#1638](https://github.com/fishtown-analytics/dbt/pull/1638)) @@ -50,7 +50,7 @@ Thanks for your contributions to dbt! - [@edmundyan](https://github.com/edmundyan) ([#1663](https://github.com/fishtown-analytics/dbt/pull/1663)) - [@vitorbaptista](https://github.com/vitorbaptista) ([#1664](https://github.com/fishtown-analytics/dbt/pull/1664)) - [@sjwhitworth](https://github.com/sjwhitworth) ([#1672](https://github.com/fishtown-analytics/dbt/pull/1672), [#1673](https://github.com/fishtown-analytics/dbt/pull/1673)) -- [@mikaelene](https://github.com/mikaelene) ([#1688](https://github.com/fishtown-analytics/dbt/pull/1688)) +- [@mikaelene](https://github.com/mikaelene) ([#1688](https://github.com/fishtown-analytics/dbt/pull/1688), [#1709](https://github.com/fishtown-analytics/dbt/pull/1709)) - [@bastienboutonnet](https://github.com/bastienboutonnet) ([#1591](https://github.com/fishtown-analytics/dbt/pull/1591), [#1689](https://github.com/fishtown-analytics/dbt/pull/1689))