Recently, upgraded my dbt to v1.3 and facing some issues with a few macros but a new compilation error keeps coming for datediff or datespine , which is not working out
Error message:
09:29:41 'dict object' has no attribute 'datediff'. This can happen when calling a macro that does not exist. Check for typos and/or install package dependencies with "dbt deps".
I’m trying to fix this so that my sessionization code works out Source: segment/segment_web_page_views__sessionized.sql at main · dbt-labs/segment · GitHub
My packages look like this : packages:
What I’ve already tried
Tested a few new macros like datespine, but the same error shows up. Also the macro does exist in dbt-utils too - so not sure what’s causing it. https://github.com/dbt-labs/dbt-utils/blob/main/macros/sql/date_spine.sql
Upgraded to dbt v1.4, but same error persists
Code part that causes errors: -
diffed AS (
--calculates `period_of_inactivity`.
SELECT
*,
{{ dbt_utils.datediff(
'previous_tstamp',
'timestamp',
'second'
) }} AS period_of_inactivity
FROM
lagged
Would appreciate any directional help here.
As of dbt 1.3 and dbt_utils 1.0, cross-database macros have moved out of dbt_utils and into the main adapter code (source), so you can just dbt.datediff()
and it will work.
I can't answer the problem you're having with date_spine without knowing what code you're using to call it, but hopefully this helps get you unblocked!