Search code examples
dbtdbt-utils

Dbt datediff - dict object compilation errors


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:

  • package: dbt-labs/dbt_utils version: “1.0.0”

What I’ve already tried

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.


Solution

  • 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!