AlenkaF opened a new issue, #40560:
URL: https://github.com/apache/arrow/issues/40560
### Describe the bug, including details regarding any error messages,
version, and platform.
If `run_ends` argument in the `pa.RunEndEncodedArray.from_arrays` is
`pyarrow.Array` object the conversion errors with `TypeError`:
```python
In [1]: import pyarrow as pa
...:
...: run_ends = pa.array([1, 3, 6], type=pa.int32())
...: values = pa.array([1, 2, 3], type=pa.int64())
...: ree_type = pa.run_end_encoded(pa.int32(), pa.int64())
...: expected = pa.RunEndEncodedArray.from_arrays(run_ends, values,
ree_type)
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
Cell In[1], line 6
4 values = pa.array([1, 2, 3], type=pa.int64())
5 ree_type = pa.run_end_encoded(pa.int32(), pa.int64())
----> 6 expected = pa.RunEndEncodedArray.from_arrays(run_ends, values,
ree_type)
File ~/repos/arrow/python/pyarrow/array.pxi:4039, in
pyarrow.lib.RunEndEncodedArray.from_arrays()
4037 """
4038 logical_length = run_ends[-1] if len(run_ends) > 0 else 0
-> 4039 return RunEndEncodedArray._from_arrays(type, True, logical_length,
4040 run_ends, values, 0)
4041
File ~/repos/arrow/python/pyarrow/array.pxi:3999, in
pyarrow.lib.RunEndEncodedArray._from_arrays()
3997 shared_ptr[CRunEndEncodedArray] ree_array
3998
-> 3999 _logical_length = <int64_t>logical_length
4000 _logical_offset = <int64_t>logical_offset
4001
TypeError: an integer is required
```
The issue seems to be that the `logical_length` variable is then a pyarrow
scalar and it can't be converted to `int64_t` integer.
```
In [3]: run_ends[-1]
Out[3]: <pyarrow.Int32Scalar: 6>
```
It works well for python lists:
```python
In [6]: run_ends = [1, 3, 6]
...: values = [1, 2, 3]
...: pa.RunEndEncodedArray.from_arrays(run_ends, values, ree_type)
Out[6]:
<pyarrow.lib.RunEndEncodedArray object at 0x104ccd780>
-- run_ends:
[
1,
3,
6
]
-- values:
[
1,
2,
3
]
```
where `logical_length` is an integer:
```
In [7]: run_ends[-1]
Out[7]: 6
```
### Component(s)
Python
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]