forked from duckdb/dbt-duckdb
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request duckdb#440 from duckdb/jwills_110_updates
Fixes to dbt-duckdb to work with DuckDB 1.1.0
- Loading branch information
Showing
2 changed files
with
14 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,12 @@ | ||
{% macro duckdb__datediff(first_date, second_date, datepart) -%} | ||
date_diff('{{ datepart }}', {{ first_date }}::timestamp, {{ second_date}}::timestamp ) | ||
{% if datepart == 'week' %} | ||
({{ datediff(first_date, second_date, 'day') }} // 7 + case | ||
when date_part('dow', ({{first_date}})::timestamp) <= date_part('dow', ({{second_date}})::timestamp) then | ||
case when {{first_date}} <= {{second_date}} then 0 else -1 end | ||
else | ||
case when {{first_date}} <= {{second_date}} then 1 else 0 end | ||
end) | ||
{% else %} | ||
(date_diff('{{ datepart }}', {{ first_date }}::timestamp, {{ second_date}}::timestamp )) | ||
{% endif %} | ||
{%- endmacro %} |