From efe5537ed2c6cb155134522aef2920dfe9b32a35 Mon Sep 17 00:00:00 2001 From: nishad shabbir Date: Tue, 11 Aug 2026 16:09:52 +0530 Subject: [PATCH] GH-50847: [Python] Add Type_RUN_END_ENCODED to _NESTED_TYPES set pyarrow.types.is_nested() answered False for run-end encoded types while the C++ arrow::is_nested() answers True for them. The Python predicate reads from a hardcoded _NESTED_TYPES set that never had Type_RUN_END_ENCODED added to it; run-end encoded was the only type the two definitions still disagreed about. Also extend test_is_nested_or_struct with map and dictionary, so the set is pinned at both ends rather than only for the types that are nested. --- python/pyarrow/tests/test_types.py | 3 +++ python/pyarrow/types.py | 3 ++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/python/pyarrow/tests/test_types.py b/python/pyarrow/tests/test_types.py index 9b5c5efe1c30..9fd46b57ca18 100644 --- a/python/pyarrow/tests/test_types.py +++ b/python/pyarrow/tests/test_types.py @@ -244,7 +244,10 @@ def test_is_nested_or_struct(): assert types.is_nested(pa.large_list(pa.int32())) assert types.is_nested(pa.list_view(pa.int32())) assert types.is_nested(pa.large_list_view(pa.int32())) + assert types.is_nested(pa.map_(pa.string(), pa.int32())) + assert types.is_nested(pa.run_end_encoded(pa.int32(), pa.string())) assert not types.is_nested(pa.int32()) + assert not types.is_nested(pa.dictionary(pa.int32(), pa.string())) def test_is_union(): diff --git a/python/pyarrow/types.py b/python/pyarrow/types.py index ab4e5d1b992a..b72427e54d0f 100644 --- a/python/pyarrow/types.py +++ b/python/pyarrow/types.py @@ -45,7 +45,8 @@ _UNION_TYPES = {lib.Type_SPARSE_UNION, lib.Type_DENSE_UNION} _NESTED_TYPES = {lib.Type_LIST, lib.Type_FIXED_SIZE_LIST, lib.Type_LARGE_LIST, lib.Type_LIST_VIEW, lib.Type_LARGE_LIST_VIEW, - lib.Type_STRUCT, lib.Type_MAP} | _UNION_TYPES + lib.Type_STRUCT, lib.Type_MAP, + lib.Type_RUN_END_ENCODED} | _UNION_TYPES class TypesEnum(IntEnum):