Describe the bug, including details regarding any error messages, version, and platform.
This issue was first posed as a question in #30302. I repeat the text here for convenience.
Overview
I have a directory of parquet files. For a specific categorical column, some parquet files use int8 and some use int16. In pyarrow 19.0.1, reading the directory as a dataset succeeds. But with pyarrow 20, it fails with the below error when loading data from the dataset directory
Reader code (python)
Either
importpandasaspddf=pd.read_parquet(
path,
engine="pyarrow",
)
or
import pyarrow.dataset as dataset
dataset = dataset.dataset(path, format="parquet")
table = dataset.to_table()
df = table.to_pandas()
Traceback
File"/app/venv/lib/python3.12/site-packages/pyarrow/parquet/core.py", line1475, inreadtable=self._dataset.to_table(
^^^^^^^^^^^^^^^^^^^^^^^File"pyarrow/_dataset.pyx", line589, inpyarrow._dataset.Dataset.to_tableFile"pyarrow/_dataset.pyx", line3941, inpyarrow._dataset.Scanner.to_tableFile"pyarrow/error.pxi", line155, inpyarrow.lib.pyarrow_internal_check_statusFile"pyarrow/error.pxi", line92, inpyarrow.lib.check_statuspyarrow.lib.ArrowInvalid: Integervalue731notinrange: -128to127
Parquet Metadata
This shows the dictionary info of the parquet files in the directory:
>>>importpyarrow.datasetasdataset>>>ds=dataset(path)
>>>forpathinds.files:
... sch=pq.read_schema(path)
... print(path, sch.field('ExpStartDate').type)
... dataframes.parq/00eac90ef2f504223a74498405e060a48.parquetdictionary<values=string, indices=int8, ordered=0>dataframes.parq/0641c30f725cd448bafc335d36cd01f6b.parquetdictionary<values=string, indices=int16, ordered=0>dataframes.parq/0cb2799478dd54c738efe76fdc1875326.parquetdictionary<values=string, indices=int8, ordered=0>dataframes.parq/0cff477be69be4ee093d98728d4f84452.parquetdictionary<values=string, indices=int16, ordered=0>dataframes.parq/0d103de6323904e93aecf24589c12a370.parquetdictionary<values=string, indices=int8, ordered=0>Is my issue related to the change in #30302 ? Is there a way to restore the previous behaviour of upcasting to int32 on read? Or what is the preferred workaround? It is going to be quite tedious to have to force all my writes to use int32, and especially for migrating huge volumes of historical data. For now we remain on pyarrow 19.0.1, but at some point we would like to upgrade.
Component(s)
C++, Parquet, Python
Describe the bug, including details regarding any error messages, version, and platform.
This issue was first posed as a question in #30302. I repeat the text here for convenience.
Overview
I have a directory of parquet files. For a specific categorical column, some parquet files use int8 and some use int16. In pyarrow 19.0.1, reading the directory as a dataset succeeds. But with pyarrow 20, it fails with the below error when loading data from the dataset directory
Reader code (python)
Either
or
Traceback
Parquet Metadata
This shows the dictionary info of the parquet files in the directory:
Is my issue related to the change in #30302 ? Is there a way to restore the previous behaviour of upcasting to int32 on read? Or what is the preferred workaround? It is going to be quite tedious to have to force all my writes to use int32, and especially for migrating huge volumes of historical data. For now we remain on pyarrow 19.0.1, but at some point we would like to upgrade.
Component(s)
C++, Parquet, Python