dbt-labs / dbt-labs/dbt-utils

[Bug] dbt_utils.date_spine gives Python error

Open
#873 7 comments 2 reactions 0 assignees View on GitHub
bug Stale triage
Dominant language
Makefile
Stars
1.8k
Forks
632
PR merge metrics
No merged PRs in 30d

Description

### Is this a new bug in dbt-core?

- [X] I believe this is a new bug in dbt-core
- [X] I have searched the existing issues, and I could not find an existing issue for this bug

### Current Behavior

Running this model and using `dbt_utils.date_spine` used to work. I now get an error I can't get to the bottom of.

### Expected Behavior

Should evaluate and give a table

### Steps To Reproduce

With dbt on local machine:
1. Define model as per below
```

{{
config(
materialized = "view" if target.name not in ['prod'] else 'table'
)
}}

WITH date_list AS
(
{{ dbt_utils.date_spine(
datepart="day",
start_date="TO_DATE('01/01/2008', 'dd/mm/yyyy')",
end_date="TO_DATE(CONCAT(YEAR(CURRENT_DATE) + 6,'-12-31'))"
)
}}

)

SELECT
*
FROM date_list;
```

2. Install the following packages
```
databricks-sdk = "==0.17.0"
dbt-databricks = "==1.6.8"
```

3. Run `dbt build -f`

### Relevant log output

```shell
Snippet

01:09:20 Completed with 1 error and 0 warnings:
01:09:20
01:09:20 Compilation Error in model dim_date (dbt_demo/models/XXX/datamarts/customer_service/dim_date.sql)
int() argument must be a string, a bytes-like object or a real number, not 'NoneType'

> in macro default__get_intervals_between (macros/sql/date_spine.sql)
> called by macro get_intervals_between (macros/sql/date_spine.sql)
> called by macro default__date_spine (macros/sql/date_spine.sql)
> called by macro date_spine (macros/sql/date_spine.sql)
> called by model dim_date (dbt_demo/models/adventureworks/datamarts/customer_service/dim_date.sql)
```

### Environment

```
- OS: MacOS 14.3 (23D56) Sonoma
- Python: 3.10.2
- dbt: 1.6.10
```

### Which database adapter are you using with dbt?

other (mention it in "Additional Context")

### Additional Context

Using dbt-databricks==1.6.8

Last seen working on Jan 24th. Then another issue came up that I only just resolved, per [issue](https://github.com/databricks/dbt-databricks/issues/609) (and hence why I fixed version of `databricks-sdk`). I haven't tested this functionality until yesterday, which is when I first noticed it was broken.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.