diff --git a/.changes/unreleased/Fixes-20220314-200236.yaml b/.changes/unreleased/Fixes-20220314-200236.yaml new file mode 100644 index 00000000000..65783acc3f5 --- /dev/null +++ b/.changes/unreleased/Fixes-20220314-200236.yaml @@ -0,0 +1,7 @@ +kind: Fixes +body: Inconsistent timestamps between inserted/updated and deleted rows in snapshots +time: 2022-03-14T20:02:36.119598832+01:00 +custom: + Author: kadero + Issue: "4347" + PR: "4513" diff --git a/core/dbt/include/global_project/macros/materializations/snapshots/strategies.sql b/core/dbt/include/global_project/macros/materializations/snapshots/strategies.sql index 9e4d7d847c4..a42e994d03a 100644 --- a/core/dbt/include/global_project/macros/materializations/snapshots/strategies.sql +++ b/core/dbt/include/global_project/macros/materializations/snapshots/strategies.sql @@ -132,17 +132,7 @@ {% set check_cols_config = config['check_cols'] %} {% set primary_key = config['unique_key'] %} {% set invalidate_hard_deletes = config.get('invalidate_hard_deletes', false) %} - - {% set select_current_time -%} - select {{ snapshot_get_time() }} as snapshot_start - {%- endset %} - - {#-- don't access the column by name, to avoid dealing with casing issues on snowflake #} - {%- set now = run_query(select_current_time)[0][0] -%} - {% if now is none or now is undefined -%} - {%- do exceptions.raise_compiler_error('Could not get a snapshot start time from the database') -%} - {%- endif %} - {% set updated_at = config.get('updated_at', snapshot_string_as_time(now)) %} + {% set updated_at = snapshot_get_time() %} {% set column_added = false %}