[C++] strptime fails to parse with %z on MacOS when zone offset includes ":"
- Dominant language
- C++
- Stars
- 17.1k
- Forks
- 4.3k
- Avg merge
- 3d 13h
- Merged PRs (30d)
- 88
Description
### Describe the bug, including details regarding any error messages, version, and platform.
Timezone information seems to be supported as per https://github.com/apache/arrow/issues/29023. And it works fine on Linux:
```
Python 3.8.14 (default, Sep 8 2022, 00:02:07)
Type 'copyright', 'credits' or 'license' for more information
IPython 8.9.0 -- An enhanced Interactive Python. Type '?' for help.
In [1]: import pyarrow
In [2]: import platform
In [3]: platform.platform()
Out[3]: 'Linux-5.15.0-1021-aws-x86_64-with-glibc2.35'
In [4]: pyarrow.__version__
Out[4]: '11.0.0'
In [5]: from pyarrow.compute import strptime
In [6]: strptime(["2012-01-01 01:02:03+01:00"], format="%Y-%m-%d %H:%M:%S%z", un
...: it="s")
Out[6]:
[
2012-01-01 00:02:03
]
```
However, it raises an error on MacOS:
```
Python 3.8.15 (default, Oct 21 2022, 23:32:29)
Type 'copyright', 'credits' or 'license' for more information
IPython 8.5.0 -- An enhanced Interactive Python. Type '?' for help.
In [1]: import pyarrow
In [2]: import platform
In [3]: platform.platform()
Out[3]: 'macOS-13.1-arm64-arm-64bit'
In [4]: pyarrow.__version__
Out[4]: '11.0.0'
In [5]: from pyarrow.compute import strptime
In [6]: strptime(["2012-01-01 01:02:03+01:00"], format="%Y-%m-%d %H:%M:%S%z", un
...: it="s")
---------------------------------------------------------------------------
ArrowInvalid Traceback (most recent call last)
Cell In [6], line 1
----> 1 strptime(["2012-01-01 01:02:03+01:00"], format="%Y-%m-%d %H:%M:%S%z", unit="s")
File ~/arrowtest/lib/python3.8/site-packages/pyarrow/compute.py:256, in _make_generic_wrapper..wrapper(memory_pool, options, *args, **kwargs)
254 if args and isinstance(args[0], Expression):
255 return Expression._call(func_name, list(args), options)
--> 256 return func.call(args, options, memory_pool)
File ~/arrowtest/lib/python3.8/site-packages/pyarrow/_compute.pyx:355, in pyarrow._compute.Function.call()
File ~/arrowtest/lib/python3.8/site-packages/pyarrow/error.pxi:144, in pyarrow.lib.pyarrow_internal_check_status()
File ~/arrowtest/lib/python3.8/site-packages/pyarrow/error.pxi:100, in pyarrow.lib.check_status()
ArrowInvalid: Failed to parse string: '2012-01-01 01:02:03+01:00' as a scalar of type timestamp[s]
```
I've looked into the umbrella issue (https://github.com/apache/arrow/issues/31324) but couldn't see this one. Sorry if I missed a duplicate issue.
### Component(s)
Python
Contributor guide
Research direction
Start with the pyarrow.compute.strptime entry point and reproduce the documented format "%Y-%m-%d %H:%M:%S%z" using the timestamp with a colon in its offset. Compare behavior on macOS and Linux; done means the input parses successfully on macOS with the expected timestamp result and regression coverage is added.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp, python
- Domain
- data
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100