From b7e8670b43e40f91e71dd6813cd1df7c175f429b Mon Sep 17 00:00:00 2001 From: Drew Banin Date: Mon, 5 Aug 2019 22:16:16 -0400 Subject: [PATCH] (#1665) Fix for casting error on old versions of postgres in snapshot queries --- .../postgres/macros/materializations/snapshot_merge.sql | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/plugins/postgres/dbt/include/postgres/macros/materializations/snapshot_merge.sql b/plugins/postgres/dbt/include/postgres/macros/materializations/snapshot_merge.sql index 7e7e0971cc3..6f8e7cbc6a5 100644 --- a/plugins/postgres/dbt/include/postgres/macros/materializations/snapshot_merge.sql +++ b/plugins/postgres/dbt/include/postgres/macros/materializations/snapshot_merge.sql @@ -5,8 +5,8 @@ update {{ target }} set dbt_valid_to = DBT_INTERNAL_SOURCE.dbt_valid_to from {{ source }} as DBT_INTERNAL_SOURCE - where DBT_INTERNAL_SOURCE.dbt_scd_id = {{ target }}.dbt_scd_id - and DBT_INTERNAL_SOURCE.dbt_change_type = 'update' + where DBT_INTERNAL_SOURCE.dbt_scd_id::text = {{ target }}.dbt_scd_id::text + and DBT_INTERNAL_SOURCE.dbt_change_type::text = 'update'::text and {{ target }}.dbt_valid_to is null; insert into {{ target }} ({{ insert_cols_csv }}) @@ -14,5 +14,5 @@ DBT_INTERNAL_SOURCE.{{ column }} {%- if not loop.last %}, {%- endif %} {%- endfor %} from {{ source }} as DBT_INTERNAL_SOURCE - where DBT_INTERNAL_SOURCE.dbt_change_type = 'insert'; + where DBT_INTERNAL_SOURCE.dbt_change_type::text = 'insert'::text; {% endmacro %}