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

int() argument must be a string, a bytes-like object or a real number, not 'NoneType' #126

Open
M39913 opened this issue May 29, 2024 · 4 comments

Comments

@M39913
Copy link

M39913 commented May 29, 2024

I tried a multiple things, see below. But I keep getting this error:

int() argument must be a string, a bytes-like object or a real number, not 'NoneType'

in macro default__get_intervals_between (macros_utils\date_spine.sql)
called by macro get_intervals_between (macros_utils\date_spine.sql)
called by macro default__date_spine (macros_utils\date_spine.sql)
called by macro date_spine (macros_utils\date_spine.sql)
called by macro default__get_base_dates (macros\get_base_dates.sql)
called by macro get_base_dates (macros\get_base_dates.sql)
called by model Datum_tabel (models\scd0\Datum_tabel.sql)

packages:

  • package: dbt-labs/dbt_utils
    version: 1.1.1
  • package: calogica/dbt_date
    version: 0.10.1

I also tried previous versions.

The model I runned:
{{ dbt_date.get_base_dates(start_date="1960-01-01", end_date="2049-12-31")}}

I also tried changing the model to this:
{{ dbt_date.get_base_dates(n_dateparts=7) }}

And this:
{{ dbt_date.get_date_dimension("1990-01-01", "2050-12-31") }}

I use databricks version 1.7.0 and dbt version 1.7.7
Please let me know your thoughts and any possible solutions :)

@clausherther
Copy link
Contributor

I was able to run both

{{ dbt_date.get_date_dimension("1990-01-01", "2050-12-31") }}

and

{{ dbt_date.get_base_dates(n_dateparts=7) }}

against BigQuery without issues. We don't really support databricks, so I can't tell you if it has to do with that adapter.
We do run integration tests against dbt-spark and run

{{ dbt_date.get_date_dimension('2015-01-01', '2022-12-31') }}

and various flavors of
{{ dbt_date.get_base_dates(n_dateparts=24*28, datepart="hour") }}

in our test date models.

@clausherther
Copy link
Contributor

Best thing would probably be to get the exact compiled run-time SQL line that's failing.

@M39913
Copy link
Author

M39913 commented May 29, 2024

Thanks for your response! I tried the tests, both of them didn't work, I got the same error.

This is the complete error by the way:
Runtime Error
Compilation Error in model Datum_tabel (models\scd0\Datum_tabel.sql)
int() argument must be a string, a bytes-like object or a real number, not 'NoneType'

> in macro default__get_intervals_between (macros\_utils\date_spine.sql)
> called by macro get_intervals_between (macros\_utils\date_spine.sql)
> called by macro default__date_spine (macros\_utils\date_spine.sql)
> called by macro date_spine (macros\_utils\date_spine.sql)
> called by macro default__get_base_dates (macros\get_base_dates.sql)
> called by macro get_base_dates (macros\get_base_dates.sql)
> called by model Datum_tabel (models\scd0\Datum_tabel.sql)

So I get the error before he compiles.
I think it has to do something with macro default__get_intervals_between

@clausherther
Copy link
Contributor

You'll need to find the actual SQL statement that fails, not the dbt macros.

get_intervals_between just calls dbt.datediff(start_date, end_date, datepart) but I don't know what dbt translates that to on databricks. You'll want to find what SQL this actually runs on your platform to see why it fails.

{%- call statement('get_intervals_between', fetch_result=True) %}

        select {{ dbt.datediff(start_date, end_date, datepart) }}

    {%- endcall -%}

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

2 participants