-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
fix: Datetime parser was incorrectly parsing 8-digit fractional seconds when format specified to expect 9 #22180
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: Datetime parser was incorrectly parsing 8-digit fractional seconds when format specified to expect 9 #22180
Conversation
7321a8f
to
211bc05
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #22180 +/- ##
==========================================
- Coverage 81.16% 81.15% -0.01%
==========================================
Files 1638 1638
Lines 235247 235253 +6
Branches 2714 2714
==========================================
- Hits 190931 190924 -7
- Misses 43676 43688 +12
- Partials 640 641 +1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
FWIW - I am not familiar with the history or detail, so consider the following observation with caution. Observation: the proposed change (from This is from looking into the performance overhead of datetime schema inference not too long ago, which is a very expensive effort in the current implementation. Something worth considering. |
Yup, thanks The underlying issue is here: #22167 (comment) looking into it to see what we can do |
when format specified to expect 9
211bc05
to
c4e4e06
Compare
if parsed == 0 { | ||
None | ||
if parsed != incr { | ||
panic!( | ||
"Invariant when calling StrpTimeState.parse was not upheld. Expected {} parsed digits, got {}.", | ||
incr, parsed | ||
); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is it ok to panic here? if we get here, it's a sign that something is seriously wrong, and it would've managed to avoid the bug pointed out in #22167 (comment)
In [21]: pl.Series(['2025-04-06T18:57:42.77756192Z']).str.to_datetime('%Y-%m-%dT%H:%M:%S.%9fcabbagebananapotato')
Out[21]:
shape: (1,)
Series: '' [datetime[ns]]
[
2025-04-06 18:57:42.077756192
]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If it is an implementation error on our end, we can panic.
OK, resolved:
|
closes #22167
Exploring this further, as this nominally fixes the issue but isn't the end of the storydone, much happier with the current fix