-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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++] Support for fractional seconds in strptime() #20146
Comments
Rok Mihevc / @rok: |
Joris Van den Bossche / @jorisvandenbossche: So as long as we use existing One option I was thinking about is when the users specifies an ISO-like format string, that we could use our own fast ISO parser, instead of using |
Joris Van den Bossche / @jorisvandenbossche: |
Rok Mihevc / @rok: |
Joris Van den Bossche / @jorisvandenbossche: >>> pc.strptime("2015-01-09 00:00:00.000", format="%Y-%m-%d %H:%M:%S.%f", unit="ns")
...
ArrowInvalid: Failed to parse string: '2015-01-09 00:00:00.000' as a scalar of type timestamp[ns] Given that we are probably not going for "%f" (based on the discussion above), it might still be useful to give a more informative error message, for example explicitly stating that "%f" is not supported. |
Carl Boettiger / @cboettig: |
Currently, we can't parse "our own" string representation of a timestamp array with the timestamp parser
strptime
:The reason for this is the fractional second part, so the following works:
Now, I think the reason that this fails is because
strptime
only supports parsing seconds as an integer (https://man7.org/linux/man-pages/man3/strptime.3.html).But, it creates a strange situation where the timestamp parser cannot parse the representation we use for timestamps.
In addition, for CSV we have a custom ISO parser (used by default), so when parsing the strings while reading a CSV file, the same string with fractional seconds does work:
I realize that you can use the generic "cast" for doing this string parsing:
But this was not the first way I thought about (I think it is quite typical to first think of
strptime
, and it is confusing that that doesn't work; the error message is also not helpful)cc @pitrou @rok
Reporter: Joris Van den Bossche / @jorisvandenbossche
Watchers: Rok Mihevc / @rok
Related issues:
Note: This issue was originally created as ARROW-15883. Please see the migration documentation for further details.
The text was updated successfully, but these errors were encountered: