apache / apache/arrow

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

Open
#44,712 0 comments 0 reactions 0 assignees View on GitHub
Component: Python Type: bug
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.

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 :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]:

[
1.000000000
]
```

### Component(s)

Python

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.