You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jira@arrow.apache.org by "ARF (Jira)" <ji...@apache.org> on 2021/02/24 16:46:00 UTC

[jira] [Created] (ARROW-11763) Dict index type ALWAYS gets coerced to int32 when saving to parquet

ARF created ARROW-11763:
---------------------------

             Summary: Dict index type ALWAYS gets coerced to int32 when saving to parquet
                 Key: ARROW-11763
                 URL: https://issues.apache.org/jira/browse/ARROW-11763
             Project: Apache Arrow
          Issue Type: Bug
          Components: Python
    Affects Versions: 3.0.0
            Reporter: ARF


On saving a pyarrow Dictionary-type column to parquet, any non-int32 index gets coerced to an int32 index without warning:


{code:python}
import pyarrow as pa
from pyarrow import parquet as pq

schema = pa.schema({
    'foo': pa.dictionary(pa.int8(), pa.string(), ordered=False),
})

def make_trivial_dict_array(dict_type, value, size):
    return 

table = pa.Table.from_pydict({
    'foo': pa.DictionaryArray.from_arrays(
        pa.nulls(1, schema.field('foo').type.index_type).fill_null(0),
        ['bar'])
})

pq.write_table(table, 'test_dict_int8.parquet', version='2.0', data_page_version='2.0')

print(f"dict index type before saving to parquet: {table.schema.field('foo').type.index_type}")

del table

table = pq.read_table('test_dict_int8.parquet')
print(f"dict index type after saving to parquet: {table.schema.field('foo').type.index_type}")
{code}

Output:

{code}
dict index type before saving to parquet: int8
dict index type after saving to parquet: int32
{code}



While this is surprising for smaller index types, coercing an in64 index to an int32 index without warning the user seems like asking for trouble.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)