Skip to content
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

Behavior of decimal array construction with numpy int64 arrays fails, but a list of ints works #44712

Open
cpcloud opened this issue Nov 13, 2024 · 0 comments

Comments

@cpcloud
Copy link
Contributor

cpcloud commented Nov 13, 2024

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

This is using PyArrow 18.0.0.

It looks like passing an array of int64 fails when trying to use that as input for constructing a decimal128 array, while using a Python list of int successfully constructs the array.

Reproducible example:

In [52]: import pyarrow as pa

In [53]: import numpy as np

In [54]: pa.array(np.array([1]), pa.decimal128(38, 9))
╭─────────────────────────────── Traceback (most recent call last) ────────────────────────────────╮
│ in <module>:1                                                                                    │
│                                                                                                  │
│ in pyarrow.lib.array:360                                                                         │
│                                                                                                  │
│ in pyarrow.lib._ndarray_to_array:87                                                              │
│                                                                                                  │
│ in pyarrow.lib.check_status:92                                                                   │
╰──────────────────────────────────────────────────────────────────────────────────────────────────╯
ArrowInvalid: Got bytestring of length 8 (expected 16)

In [55]: pa.array([1], pa.decimal128(38, 9))
Out[55]:
<pyarrow.lib.Decimal128Array object at 0x7f0ccef07040>
[
  1.000000000
]

Component(s)

Python

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant