apache / apache/arrow

[Python] Incorrect results when reading a buffer of boolean values

Open
#31,494 5 comments 0 reactions 0 assignees View on GitHub
Component: Python Type: bug
Dominant language
C++
Stars
17.1k
Forks
4.3k
Avg merge
3d 20h
Merged PRs (30d)
94

Description

The following reproducer demonstrates that a buffer of boolean values is not correctly recovered when using pyarrow.

```python

import pyarrow.parquet as pq
import pyarrow as pa
import numpy as np

if __name__ == "__main__":

data = np.array([True, False, True, False], dtype=bool)

length = len(data)

buf = pa.py_buffer(data)

array = pa.Array.from_buffers(pa.bool_(), length, [None, buf])

np.testing.assert_array_equal(data, array.to_numpy(zero_copy_only=False))

```

**Environment**: Ubuntu 20.04, Python 3.8.10, pyarrow==7.0.0
**Reporter**: [Jonathan Kenyon](https://issues.apache.org/jira/browse/ARROW-16081)

**Note**: *This issue was originally created as [ARROW-16081](https://issues.apache.org/jira/browse/ARROW-16081). Please see the [migration documentation](https://github.com/apache/arrow/issues/14542) for further details.*

Contributor guide

Open the contributing guide

Research direction

Start by running the provided Python reproducer with pyarrow 7.0.0 and inspect the Array.from_buffers and array.to_numpy entry points involved in boolean buffers. Done means the resulting NumPy array matches the original [True, False, True, False] values and the assertion passes.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
data
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.