From ae6cc736b7445120c7e86da8a597879a6a4f8b13 Mon Sep 17 00:00:00 2001 From: Daniel Pollak Date: Tue, 26 Sep 2023 11:09:09 +0300 Subject: [PATCH] . --- macros/utils/cross_db_utils/datediff.sql | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/macros/utils/cross_db_utils/datediff.sql b/macros/utils/cross_db_utils/datediff.sql index be7cfcd60..41939cc4d 100644 --- a/macros/utils/cross_db_utils/datediff.sql +++ b/macros/utils/cross_db_utils/datediff.sql @@ -2,7 +2,7 @@ {{ return(adapter.dispatch('edr_datediff', 'elementary')(first_date, second_date, date_part)) }} {% endmacro %} -{# For Snowflake, Databricks, Redshift, Postgres & Spark #} +{# For Snowflake, Databricks, Redshift, Postgres #} {# the dbt adapter implementation supports both timestamp and dates #} {% macro default__edr_datediff(first_date, second_date, date_part) %} {% set macro = dbt.datediff or dbt_utils.datediff %} @@ -26,7 +26,8 @@ {%- endif %} {% endmacro %} - +{# dbt-spark implementation has an off by one for datepart == "hour" #} +{# because it uses CEIL instead of FLOOR #} {% macro spark__edr_datediff(first_date, second_date, datepart) %} {%- if datepart in ['day', 'week', 'month', 'quarter', 'year'] -%}