[Python] pa.DictionaryArray.from_arrays(..) can't convert large numpy / ndarrays
- Vorherrschende Sprache
- C++
- Sterne
- 17.1k
- Forks
- 4.3k
- Ø Merge
- 3 T. 18 Std.
- Gemergte PRs (30 T.)
- 91
Beschreibung
### Describe the bug, including details regarding any error messages, version, and platform.
Numpy arrays seem to get converted with pyarrow.array(..) either to pyarrow.Array OR pyarrow.ChunkedArray depending on its' size according to the documentation.
The pa.DictionaryArray.from_arrays(..) is also specified, that it can treat ndarrays, but in case the ndarray is a large object, there is an internal exception which is not able to treat the ChunkedArray object.
```
import pyarrow as pa
import numpy as np
# 300 MB binary blobs × 10 = 3 GB of total data
blob = b'x' * (300 * 1024 * 1024)
data = [blob] * 10
a = (np.array(data))
# test conversion to pyarrow array
print(type(pa.array(a))) # -> pyarrow.lib.ChunkedArray
indices = np.array(list(range(10)))
# this throws an error, even if a is a legit numpy array
pa.DictionaryArray.from_arrays(indices, a)
'''
------- RESULT ----------
Traceback (most recent call last):
File "", line 1, in
File "pyarrow\\array.pxi", line 4091, in pyarrow.lib.DictionaryArray.from_arrays
TypeError: Cannot convert pyarrow.lib.ChunkedArray to pyarrow.lib.Array
'''
``
### Component(s)
Python
Beitragsleitfaden
Rechercherichtung
Beginnen Sie mit dem gemeldeten Reproducer unter Verwendung von pa.array(a) und DictionaryArray.from_arrays(indices, a), und bestätigen Sie, dass ein großes NumPy ndarray zu einem ChunkedArray wird. Verfolgen Sie die Python-Binding-Einstiegspunkte für diese beiden APIs und bestimmen Sie, wie der ChunkedArray-Fall behandelt werden sollte; abgeschlossen ist die Aufgabe, wenn große ndarrays nicht mehr den gemeldeten TypeError auslösen.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- numpy, python
- Bereich
- data
- Issue-Typ
- Bug
- Schwierigkeit
- 4/5
- Geschätzter Aufwand
- 3-5 Tage
- Aktivitätsstatus
- Veraltet
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 35/100