From 9a497ef52bc23c255c879d143f15e86e90ba55b5 Mon Sep 17 00:00:00 2001 From: Theo Kiehn <162969167+tkiehn@users.noreply.github.com> Date: Wed, 6 Nov 2024 17:51:39 +0100 Subject: [PATCH] fix/redshift: replace dateadd() with inverval arithmetics --- macros/tables/redshift/pit.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/macros/tables/redshift/pit.sql b/macros/tables/redshift/pit.sql index b576f739..a3b270db 100644 --- a/macros/tables/redshift/pit.sql +++ b/macros/tables/redshift/pit.sql @@ -82,7 +82,7 @@ pit_records AS ( SELECT {{ hashkey }}, {{ ldts }}, - COALESCE(LEAD(DATEADD(microsecond,-1, {{ ldts }})) OVER (PARTITION BY {{ hashkey }} ORDER BY {{ ldts }}),{{ datavault4dbt.string_to_timestamp(timestamp_format, end_of_all_times) }}) AS {{ ledts }} + COALESCE(LEAD({{ ldts }} - interval '00:00:00.000001') OVER (PARTITION BY {{ hashkey }} ORDER BY {{ ldts }}),{{ datavault4dbt.string_to_timestamp(timestamp_format, end_of_all_times) }}) AS {{ ledts }} FROM {{ ref(satellite) }} ) {{ satellite }} {% endif %}