Skip to content

[Python] Casting round double scalars to temporal types raising ArrowNotImplementedError on pyarrow 13 dev #36677

@mroeschke

Description

@mroeschke

Describe the bug, including details regarding any error messages, version, and platform.

>>> import pyarrow as pa
>>> pa.__version__
'12.0.1'
>>> pa.scalar(43260.0).cast(pa.time32("s"))
<pyarrow.Time32Scalar: datetime.time(12, 1)>

>>> pa.__version__
'13.0.0.dev497'
>>> pa.scalar(43260.0).cast(pa.time32("s"))
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "pyarrow/scalar.pxi", line 91, in pyarrow.lib.Scalar.cast
  File "/opt/miniconda3/envs/pyarrow-pandas-dev/lib/python3.11/site-packages/pyarrow/compute.py", line 403, in cast
    return call_function("cast", [arr], options, memory_pool)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "pyarrow/_compute.pyx", line 572, in pyarrow._compute.call_function
  File "pyarrow/_compute.pyx", line 367, in pyarrow._compute.Function.call
  File "pyarrow/error.pxi", line 144, in pyarrow.lib.pyarrow_internal_check_status
  File "pyarrow/error.pxi", line 121, in pyarrow.lib.check_status
pyarrow.lib.ArrowNotImplementedError: Unsupported cast from double to time32 using function cast_time32

Not sure if this will be an intentional change, but it appears casting from double to temporal types has changed. In theory for the example above 43260.0 can be cast exactly back to datetime.time(12, 1). I could see how for a value like 43260.1 there would be implicit rounding in pyarrow 12

Component(s)

Python

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions