diff --git a/python/pyarrow/tests/test_types.py b/python/pyarrow/tests/test_types.py index bb2a986a352..60cd5be0ad2 100644 --- a/python/pyarrow/tests/test_types.py +++ b/python/pyarrow/tests/test_types.py @@ -210,6 +210,12 @@ def test_types_picklable(): assert pickle.loads(data) == ty +def test_dictionary_type(): + ty = pa.dictionary(pa.int32(), pa.array(['a', 'b', 'c'])) + assert ty.index_type == pa.int32() + assert ty.dictionary.to_pylist() == ['a', 'b', 'c'] + + def test_fields_hashable(): in_dict = {} fields = [pa.field('a', pa.int64()), diff --git a/python/pyarrow/types.pxi b/python/pyarrow/types.pxi index 850be23fcd5..9cd9bede6e0 100644 --- a/python/pyarrow/types.pxi +++ b/python/pyarrow/types.pxi @@ -184,6 +184,16 @@ cdef class DictionaryType(DataType): def __get__(self): return self.dict_type.ordered() + property index_type: + + def __get__(self): + return pyarrow_wrap_data_type(self.dict_type.index_type()) + + property dictionary: + + def __get__(self): + return pyarrow_wrap_array(self.dict_type.dictionary()) + cdef class ListType(DataType):