-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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
[C++][Python] Crashes and incorrect results when converting large integers to dates #27842
Comments
David Li / @lidavidm: In all cases, it's because the given date either overflows or is an invalid value for the underlying C++ date type. I'm not sure if we should disallow these values entirely, since the format (as far as I can see) says nothing about the range of valid values, and the underlying value is valid, if extreme - but at least you'd expect it to not crash when printing. I see @bkietz and @jorisvandenbossche have looked at similar issues before - what do you think? Trimmed backtrace for the crash. The main issue is that the date::year_month_day value is invalid (in particular, the year is invalid, it's -32768).
|
Joris Van den Bossche / @jorisvandenbossche:
I agree that if the format doesn't mention anything about a valid range, we should allow that but of course ensure this doesn't crash when printing.
I think that might be about the fact that for The date library that we use (vendor) for this formatting is https://github.com/HowardHinnant/date, it might possibly also be worth updating our vendored version. |
David Li / @lidavidm: It's worth seeing if an updated date helps, though I saw issues like HowardHinnant/date#436 suggesting that overflow is really the user's responsibility. (It is a little odd in that while the documentation states year::ok is always true, that's not actually the case as implemented.) |
Antoine Pitrou / @pitrou: |
Running this code snippet will cause a crash. This happens for a range of numbers around this one as well:
I don't know where this crash is coming from, so it might be in the C++ code rather than the Python bindings.
For other extreme numbers you get the wrong result. It looks like something is overflowing. Here is the input and result for a few different examples:
-2000000000 -> 31179-12-27
-1000000000 -> 16574-12-29
2000000000 -> -27240-01-06
1000000000 -> -12635-01-03
I would prefer if these gave errors rather than silently overflowing.
Environment: OS: Windows 10 Pro (Version 20H2)
CPU: AMD Ryzen 5 1600 Six-Core Processor 3.20 GHz
Python: 3.8.8 AMD64
pyarrow is latest version installed with pip
Reporter: Tim Evans
Assignee: Antoine Pitrou / @pitrou
Related issues:
PRs and other links:
Note: This issue was originally created as ARROW-12011. Please see the migration documentation for further details.
The text was updated successfully, but these errors were encountered: