When working with medium-sized datasets that have very long strings, arrow fails when trying to operate on the strings. The root is the combine_chunks function.
Here is a minimally reproducible example
importnumpyasnpimportpyarrowaspa# Create a large stringx=str(np.random.randint(low=0,high=1000, size=(30000,)).tolist())
t=pa.chunked_array([x]*20_000)
# Combine the chunks into large string array - failscombined=t.combine_chunks()
I get the following error
---------------------------------------------------------------------------ArrowInvalidTraceback (mostrecentcalllast) /var/folders/x6/00594j4s2yv3swcn98bn8gxr0000gn/T/ipykernel_95780/4128956270.pyin<module>---->1z=t.combine_chunks()
~/.venv/lib/python3.7/site-packages/pyarrow/table.pxiinpyarrow.lib.ChunkedArray.combine_chunks() ~/.venv/lib/python3.7/site-packages/pyarrow/array.pxiinpyarrow.lib.concat_arrays() ~/Documents/Github/dataquality/.venv/lib/python3.7/site-packages/pyarrow/error.pxiinpyarrow.lib.pyarrow_internal_check_status() ~.venv/lib/python3.7/site-packages/pyarrow/error.pxiinpyarrow.lib.check_status() ArrowInvalid: offsetoverflowwhileconcatenatingarrays
With smaller strings or smaller arrays this works fine.
x=str(np.random.randint(low=0,high=1000, size=(10,)).tolist())
t=pa.chunked_array([x]*1000)
combined=t.combine_chunks()
The first example that fails takes a few minutes to run. If you'd like a faster example for experimentation, you can use vaex to generate the chunked array much faster. This will throw the identical error and will run about 1 second.
importvaeximportnumpyasnpn=50_000x=str(np.random.randint(low=0,high=1000, size=(30_000,)).tolist())
df=vaex.from_arrays(
id=list(range(n)),
y=np.random.randint(low=0,high=1000,size=n)
)
df["text"] =vaex.vconstant(x, len(df))
# text_chunk_array is now a pyarrow.lib.ChunkedArraytext_chunk_array=df.text.valuesx=text_chunk_array.combine_chunks()
Reporter: Ben Epstein
Related issues:
Note: This issue was originally created as ARROW-17828. Please see the migration documentation for further details.
When working with medium-sized datasets that have very long strings, arrow fails when trying to operate on the strings. The root is the
combine_chunksfunction.Here is a minimally reproducible example
I get the following error
With smaller strings or smaller arrays this works fine.
The first example that fails takes a few minutes to run. If you'd like a faster example for experimentation, you can use
vaexto generate the chunked array much faster. This will throw the identical error and will run about 1 second.Reporter: Ben Epstein
Related issues:
Note: This issue was originally created as ARROW-17828. Please see the migration documentation for further details.