You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Python] Table.to_pandas() fails for dictionary encoded columns with an is_null partition_expression #32225
I attached a .zip file containing a python script and a test parquet file. Running this python script reproduces the issue.
The steps taken to reproduce:
Create a test parquet file with one column containing only null.
Create a parquet fragment from this file adding a partition_expression with an is_null guarantee on this fragment.
Create a FileSystemDataset from this fragment setting the schema to be a dictionary column.
Call .to_table().to_pandas() on the resulting pyarrow dataset. You will get the following error.
File"/.../pip-core_pandas/pandas/core/dtypes/dtypes.py", line492, invalidate_categoriesraiseValueError("Categorical categories cannot be null")
ValueError: Categoricalcategoriescannotbenull
My understanding of why this doesn't work:
There are 2 ways of dictionary encoding nulls: mask and encode described in the pyarrow docs. Pyarrow supports both but pandas categoricals only supports mask. Arguably the real issue here is pandas should support encode style categoricals.
When you provide an .is_null guarantee on a fragment arrow will not actually read the data. It knows the type from the schema, we've guaranteed the values are all null and it can get the length from the parquet metadata so it has everything it needs.
Instead of reading the data it uses the Null ArrayFactory. For dictionary type columns I believe that calls this DictionaryArray constructor which appears to be creating the dictionary in the encode style.
Would it be possible to make this configurable? It seems like the mask style of dictionary encoding is the default for the rest of PyArrow and it would solve the Pandas compatibility issue. I appreciate this is probably an extremely niche issue but my options for a workaround are looking pretty horrible.
Environment: Ubuntu 18.04, PyArrow 8.0.0, Pandas 1.4.3 Reporter: Thomas Newton
Activity
thisisnic commentedon Oct 26, 2026
Reproduces on 26.0.0