Add DATE to dateadd macro
Fixes #405
tl;dr, helps you avoid errors like:
Binder Error: Could not choose a best candidate function for the function call "+(STRING_LITERAL, INTERVAL)". In order to select one, please add explicit type casts. Candidate functions:
+(DATE, INTERVAL) -> TIMESTAMP
+(TIME, INTERVAL) -> TIME
+(TIMESTAMP, INTERVAL) -> TIMESTAMP
+(TIME WITH TIME ZONE, INTERVAL) -> TIME WITH TIME ZONE
+(TIMESTAMP WITH TIME ZONE, INTERVAL) -> TIMESTAMP WITH TIME ZONE
+(INTERVAL, INTERVAL) -> INTERVAL
LINE 1: /* {"app": "dbt", "dbt_version": "1.7.9", "profile_...
See docs here: https://duckdb.org/docs/sql/functions/date.html
I didn't have time to setup integration tests, but tested the updated macro locally, and 'correct' example now works:
SELECT {{ dateadd(datepart="month", interval=1, from_date_or_timestamp="'2021-08-12'") }} AS period_of_load
yeah I'm surprised this didn't break on the regular unit tests-- like, does this not work anymore and I missed it? https://github.com/dbt-labs/dbt-adapters/blob/main/dbt-tests-adapter/dbt/tests/adapter/utils/fixture_dateadd.py
Possibly those are more explicit strings? So inference can work?
My concern here is what happens if I pass in a TIMESTAMP instead of a string or a DATE? Or a string that should be cast as a TIMESTAMP instead?
Yeh... Interestingly in DuckDb the dateadd operations seem to expect the coder to know and set the type ahead of time in the statement? https://duckdb.org/docs/sql/functions/interval
Closing this out as I believe the code was working the way dbt intended