diff --git a/python/pyarrow/includes/libarrow.pxd b/python/pyarrow/includes/libarrow.pxd index 455d11d39e84..3e0c64eead41 100644 --- a/python/pyarrow/includes/libarrow.pxd +++ b/python/pyarrow/includes/libarrow.pxd @@ -204,6 +204,7 @@ cdef extern from "arrow/api.h" namespace "arrow" nogil: c_bool is_primitive(Type type) c_bool is_numeric(Type type) + c_bool is_nested(Type type) cdef cppclass CArrayStatistics" arrow::ArrayStatistics": optional[CArrayStatisticsCountType] null_count diff --git a/python/pyarrow/types.pxi b/python/pyarrow/types.pxi index f9530a34362f..4f1bb0f652b5 100644 --- a/python/pyarrow/types.pxi +++ b/python/pyarrow/types.pxi @@ -161,6 +161,11 @@ def _is_primitive(Type type): return is_primitive(type) +def _is_nested(Type type): + # This is simply a redirect, the official API is in pyarrow.types. + return is_nested(type) + + def _get_pandas_type(arrow_type, coerce_to_ns=False): cdef Type type_id = arrow_type.id cdef dict pandas_type_map = _get_pandas_type_map() diff --git a/python/pyarrow/types.py b/python/pyarrow/types.py index 859bcd21abff..d2efe5d3da0c 100644 --- a/python/pyarrow/types.py +++ b/python/pyarrow/types.py @@ -43,10 +43,6 @@ lib.Type_DURATION} | _TIME_TYPES | _DATE_TYPES | _INTERVAL_TYPES) _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, - lib.Type_RUN_END_ENCODED} | _UNION_TYPES class TypesEnum(IntEnum): @@ -257,7 +253,7 @@ def is_union(t): @doc(is_null, datatype="nested type") def is_nested(t): - return t.id in _NESTED_TYPES + return lib._is_nested(t.id) @doc(is_null, datatype="run-end encoded")