dbt-duckdb icon indicating copy to clipboard operation
dbt-duckdb copied to clipboard

Duck Db support of DATEADD from Core

Open alittlesliceoftom opened this issue 1 year ago • 1 comments

I tried the example here: https://docs.getdbt.com/sql-reference/dateadd

SELECT {{ dateadd(datepart="month", interval=1, from_date_or_timestamp="'2021-08-12'") }}

This fails.

I tweaked and this works:

SELECT {{ dateadd(datepart="month", interval=1, from_date_or_timestamp="DATE '2021-08-12'") }}  AS period_of_load

In general I think adapters should support the documented case from core.

Here duckdb seems to want date strings to be explicitly refererred to as dates in addition operations as per: https://duckdb.org/docs/sql/functions/date.html

As such I suggest that : https://github.com/duckdb/dbt-duckdb/blob/master/dbt/include/duckdb/macros/utils/dateadd.sql

Is updated to include: DATE at start

alittlesliceoftom avatar Jun 19 '24 14:06 alittlesliceoftom

Context, I'm trying to complete this issue: https://github.com/alittlesliceoftom/insert_by_timeperiod/issues/2 on the insert by timeperiod repo, and struggling here with duck db compatability.

alittlesliceoftom avatar Jun 19 '24 14:06 alittlesliceoftom