diff --git a/macros/tables/databricks/pit.sql b/macros/tables/databricks/pit.sql index 29601647..6b6d71e1 100644 --- a/macros/tables/databricks/pit.sql +++ b/macros/tables/databricks/pit.sql @@ -80,7 +80,7 @@ pit_records AS ( SELECT {{ hashkey }}, {{ ldts }}, - COALESCE(LEAD(TIMESTAMP_SUB({{ ldts }}, INTERVAL 1 MICROSECOND)) OVER (PARTITION BY {{ hashkey }} ORDER BY {{ ldts }}),{{ datavault4dbt.string_to_timestamp(timestamp_format, end_of_all_times) }}) AS {{ ledts }} + COALESCE(LEAD(({{ldts}} - INTERVAL 1 MICROSECOND)) OVER (PARTITION BY {{ hashkey }} ORDER BY {{ ldts }}),{{ datavault4dbt.string_to_timestamp(timestamp_format, end_of_all_times) }}) AS {{ ledts }} FROM {{ ref(satellite) }} ) {{ satellite }} {% endif %} diff --git a/macros/tables/postgres/pit.sql b/macros/tables/postgres/pit.sql index 4927e7ae..8ae32894 100644 --- a/macros/tables/postgres/pit.sql +++ b/macros/tables/postgres/pit.sql @@ -80,7 +80,7 @@ pit_records AS ( SELECT {{ hashkey }}, {{ ldts }}, - COALESCE(LEAD(TIMESTAMP_SUB({{ ldts }}, INTERVAL 1 MICROSECOND)) OVER (PARTITION BY {{ hashkey }} ORDER BY {{ ldts }}),{{ datavault4dbt.string_to_timestamp(timestamp_format, end_of_all_times) }}) AS {{ ledts }} + COALESCE(LEAD({{ ldts }} - INTERVAL '1 MICROSECOND') OVER (PARTITION BY {{ hashkey }} ORDER BY {{ ldts }}),{{ datavault4dbt.string_to_timestamp(timestamp_format, end_of_all_times) }}) AS {{ ledts }} FROM {{ ref(satellite) }} ) {{ satellite }} {% endif %} 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 %}