diff --git a/python/pyarrow/tests/test_types.py b/python/pyarrow/tests/test_types.py index 09f0dfe7d37df..568702d8e888f 100644 --- a/python/pyarrow/tests/test_types.py +++ b/python/pyarrow/tests/test_types.py @@ -580,6 +580,10 @@ def test_map_type(): assert ty == ty_metadata assert not ty.equals(ty_metadata, check_metadata=True) + for keys_sorted in [True, False]: + assert pa.map_(pa.utf8(), pa.int32(), + keys_sorted=keys_sorted).keys_sorted == keys_sorted + with pytest.raises(TypeError): pa.map_(None) with pytest.raises(TypeError): diff --git a/python/pyarrow/types.pxi b/python/pyarrow/types.pxi index 4ad2536368e3f..c02d036e0f57b 100644 --- a/python/pyarrow/types.pxi +++ b/python/pyarrow/types.pxi @@ -536,6 +536,19 @@ cdef class MapType(DataType): """ return pyarrow_wrap_data_type(self.map_type.item_type()) + @property + def keys_sorted(self): + """ + Should the entries be sorted according to keys. + + Examples + -------- + >>> import pyarrow as pa + >>> pa.map_(pa.string(), pa.int32(), keys_sorted=True).keys_sorted + True + """ + return self.map_type.keys_sorted() + cdef class FixedSizeListType(DataType): """