apache / apache/arrow

[Python] pa.DictionaryArray.from_arrays(..) can't convert large numpy / ndarrays

Ouverte
#47,246 0 commentaires 0 réactions 0 personnes assignées Voir sur GitHub
Component: Python Type: bug
Langage dominant
C++
Étoiles
17.1k
Forks
4.3k
Merge moyen
3 j 23 h
PR mergées (30 j)
101

Description

### 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

Guide de contribution

Ouvrir le guide de contribution

Piste de recherche

Commencez par le reproducer fourni en utilisant pa.array(a) et DictionaryArray.from_arrays(indices, a), en vérifiant qu’un grand ndarray NumPy devient un ChunkedArray. Suivez les points d’entrée des bindings Python pour ces deux APIs et déterminez comment le cas ChunkedArray doit être traité ; le travail est terminé lorsque les grands ndarrays ne lèvent plus le TypeError signalé.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Évaluation

Stack technique
numpy, python
Domaine
data
Type d'issue
Bug
Difficulté
4/5
Temps estimé
3-5 jours
Activité
À l'abandon
Clarté
Plutôt claire
Accessibilité débutants
35/100

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.