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

fix(rust): Don't silently produce null values from invalid input to pl.datetime and pl.date #21013

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

mcrumiller
Copy link
Contributor

@mcrumiller mcrumiller commented Jan 30, 2025

Fixes #20977.

I am not sure if this is a breaking change or not.

Raising a better exception type here would slow down the loop so for now we just raise a PanicException. I don't believe that we generally handle datetime errors elegantly elsewhere (see #19708 (comment), although I'm not sure which issue that's referring to exactly).

Example of new behavior:

>>> import polars as pl
>>> pl.select(pl.date(2025, 13, 1))  # month 13 is invalid (pl.Date)
pyo3_runtime.PanicException: Invalid date components (2025, 13, 1) supplied

>>> pl.select(pl.datetime(2025, 13, 1))  # month 13 is invalid (pl.Datetime)
pyo3_runtime.PanicException: Invalid date components (2025, 13, 1) supplied


>>> pl.select(pl.datetime(2025, 1, 1, 25))  # hour 25 is invalid
pyo3_runtime.PanicException: Invalid time components (25, 0, 0, 0) supplied

@github-actions github-actions bot added fix Bug fix rust Related to Rust Polars labels Jan 30, 2025
Copy link

codecov bot commented Jan 30, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 79.21%. Comparing base (96a2d01) to head (b3b2a0c).
Report is 23 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #21013      +/-   ##
==========================================
- Coverage   79.34%   79.21%   -0.13%     
==========================================
  Files        1579     1583       +4     
  Lines      224319   225110     +791     
  Branches     2573     2581       +8     
==========================================
+ Hits       177976   178312     +336     
- Misses      45755    46208     +453     
- Partials      588      590       +2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@mcrumiller mcrumiller marked this pull request as ready for review January 30, 2025 17:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
fix Bug fix rust Related to Rust Polars
Projects
None yet
Development

Successfully merging this pull request may close these issues.

pl.datetime does not raise with argument values outside of the specified domain
1 participant