Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

date_spine isn't working with dbt_utils 1.1.0 #96

Closed
romiof opened this issue Jun 2, 2023 · 6 comments
Closed

date_spine isn't working with dbt_utils 1.1.0 #96

romiof opened this issue Jun 2, 2023 · 6 comments

Comments

@romiof
Copy link

romiof commented Jun 2, 2023

Hello!

I'm trying to run a date_spine to populate my Calendar Dimension, but it crash with Compilation Error:

23:29:43  Running with dbt=1.4.6
23:29:44  Encountered an error:
Compilation Error in model DimCalendar (models/03_dimensions/DimCalendar.sql)
  'dict object' has no attribute 'datediff'
  
  > in macro sqlserver__date_spine (macros/dbt_utils/datetime/date_spine.sql)
  > called by macro date_spine (macros/sql/date_spine.sql)
  > called by model DimCalendar (models/03_dimensions/DimCalendar.sql)

Version info:

dbt --version
Core:
  - installed: 1.4.6
  - latest:    1.5.1 - Update available!

  Your version of dbt-core is out of date!
  You can find instructions for upgrading here:
  https://docs.getdbt.com/docs/installation

Plugins:
  - sqlserver: 1.4.3 - Up to date!
packages:
  - package: dbt-labs/dbt_utils
    version: ["1.1.0"]
  - package: calogica/dbt_date
    version: ["0.7.2"]
  - package: dbt-msft/tsql_utils
    version: ["0.9.0"]

With a regression to dbt_utils 0.9.0 date_spine worked, but had some warns:

> Executing task: dbt compile --model DimCalendar
23:35:07  Running with dbt=1.4.6
23:35:07  [WARNING]: Configuration paths exist in your dbt_project.yml file which do not apply to any resources.
There are 1 unused configuration paths:
- tests
23:35:07  Found 65 models, 0 tests, 0 snapshots, 1 analysis, 695 macros, 0 operations, 10 seed files, 199 sources, 0 exposures, 0 metrics
23:35:07  
23:35:08  Concurrency: 4 threads (target='dev')
23:35:08  
23:35:08  Warning: the `datediff` macro is now provided in dbt Core. It is no longer available in dbt_utils and backwards compatibility will be removed in a future version of the package. Use `datediff` (no prefix) instead. The dbt_sazi.DimCalendar model triggered this warning.
23:35:08  Warning: the `dateadd` macro is now provided in dbt Core. It is no longer available in dbt_utils and backwards compatibility will be removed in a future version of the package. Use `dateadd` (no prefix) instead. The dbt_sazi.DimCalendar model triggered this warning.
23:35:08  Done.
@romiof
Copy link
Author

romiof commented Jun 2, 2023

My model content:

{{ dbt_utils.date_spine(
    datepart="day",
    start_date="cast('2020-01-01' as date)",
    end_date="cast('2020-01-31' as date)"
   )
}}

@brent3-work
Copy link

I am also have this exact same problem. I believe that Pull Request #90 will fix this issue. Problem is that dbt-core was updated to include dateadd and datediff among other cross-database macros and dbt-utils was subsequently modified, but in the current (0.9.0) version of tsql-utils the date_spine is still referencing dbt_util.dateadd and dbt_util.datediff intead of dbt.dateadd and dbt.datediff. The pull request fixes that.

@ghost
Copy link

ghost commented Aug 9, 2023

I am having the exact same Problem, adjusting the tsql_utils date _spine macro from dbt_utils.datediff to dbt.datediff fixes the issue, as @brent3-work proposed.

@joaquinbravo23
Copy link
Contributor

joaquinbravo23 commented Dec 22, 2023

#100

I proposed a bugfix on this PR.

@mycaule
Copy link

mycaule commented May 7, 2024

I had the same problem here running on Linux on a remote build VM with,

  • dbt-core==1.7.14
  • dbt-sqlserver==1.7.4
  • dbt-labs/dbt_utils==1.1.1
  • dbt-labs/audit_helper==0.11.0
  • dbt-msft/tsql_utils==0.10.0

Didn't have the problem on my development desktop running on MacOS though.

and @joaquinbravo23 patch solved my problem, thanks to him for spotting the problem.

sdebruyn added a commit that referenced this issue Sep 7, 2024
Bug fix proposal on issue related to #96
@sdebruyn
Copy link
Member

sdebruyn commented Sep 8, 2024

should be fixed, report back if not please

@sdebruyn sdebruyn closed this as completed Sep 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants