Skip to content

fix: support string, date, and datetime bounds in polars fill_gaps - #302

Open
Jakub Krasuski (Blizzeq) wants to merge 3 commits into
Nixtla:mainfrom
Blizzeq:fix/fill-gaps-polars-bound
Open

Jakub Krasuski (Blizzeq) wants to merge 3 commits into
Nixtla:mainfrom
Blizzeq:fix/fill-gaps-polars-bound

Conversation

@Blizzeq

@Blizzeq Jakub Krasuski (Blizzeq) commented Oct 10, 2026 •

Copy link
Copy Markdown
Contributor

When calling fill_gaps on a Polars DataFrame with a custom start or end timestamp (such as a string like '2020-01-01', a date, or a datetime), _determine_bound_pl created a Series([val]) without matching the target dtype of the time column. This caused a panic in datetime_ranges when passed string series, or a schema error when joining differing datetime and date keys.

This PR ensures _determine_bound_pl converts scalar bounds (strings, dates, datetimes) to match the time column's target dtype in Polars before building the grid. Added regression tests covering string, date, and datetime bounds on Polars.

@jmoralez José Morales (jmoralez) left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey Jakub Krasuski (@Blizzeq), thanks for your interest in this issue. We try to mimic what each backend supports so pandas allows using strings as dates/datetimes but polars always uses date and datetime objects. we used to have this distinction in the docs but they were migrated to the tests.

What I'd prefer here would be to add a check in the polars branch to see if the bound and the time column don't match and raise a clear error there, e.g. bound is datetime but time column is date.

@Blizzeq Jakub Krasuski (Blizzeq) changed the title fix: support string, date, and datetime bounds in polars fill_gaps fix: raise a clear error for mismatched start/end in polars fill_gaps Oct 12, 2026
@Blizzeq

Copy link
Copy Markdown
Contributor Author

Makes sense, thanks. I dropped the conversion and added a check in the polars branch instead: start and end now have to match the time column, otherwise fill_gaps raises a ValueError that names the argument and the expected type.

@jmoralez

Copy link
Copy Markdown
Contributor

Hey Jakub Krasuski (@Blizzeq), I'm very sorry but on a second thought I prefer your first approach. Can you please revert the latest commit so we can pick up from there?

@Blizzeq Jakub Krasuski (Blizzeq) changed the title fix: raise a clear error for mismatched start/end in polars fill_gaps fix: support string, date, and datetime bounds in polars fill_gaps Oct 16, 2026
@Blizzeq

Copy link
Copy Markdown
Contributor Author

No problem, reverted in 19dda74 so the branch is back to the conversion approach from the first commit.

This branch has not been deployed

No deployments
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

Successfully merging this pull request may close these issues.

2 participants