This is an automated email from the ASF dual-hosted git repository.

jorisvandenbossche pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/arrow.git


The following commit(s) were added to refs/heads/main by this push:
     new 3f7b2884dc GH-40171: [Python] Add Type_FIXED_SIZE_LIST to 
_NESTED_TYPES set (#40172)
3f7b2884dc is described below

commit 3f7b2884dccb4c0164092b754a2a76ccbb900154
Author: Hussein Awala <[email protected]>
AuthorDate: Tue Feb 27 14:28:55 2024 +0100

    GH-40171: [Python] Add Type_FIXED_SIZE_LIST to _NESTED_TYPES set (#40172)
    
    
    
    ### Rationale for this change
    
    ### What changes are included in this PR?
    
    This PR fixes a minor bug in `types.is_nested` which doesn't consider the 
`FIXED_SIZE_LIST` type as nested type.
    
    ### Are these changes tested?
    
    ### Are there any user-facing changes?
    
    * Closes: #40171
    
    Authored-by: hussein-awala <[email protected]>
    Signed-off-by: Joris Van den Bossche <[email protected]>
---
 python/pyarrow/tests/test_types.py | 1 +
 python/pyarrow/types.py            | 4 ++--
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/python/pyarrow/tests/test_types.py 
b/python/pyarrow/tests/test_types.py
index 0add578608..e048ed6fa5 100644
--- a/python/pyarrow/tests/test_types.py
+++ b/python/pyarrow/tests/test_types.py
@@ -214,6 +214,7 @@ def test_is_nested_or_struct():
 
     assert types.is_nested(struct_ex)
     assert types.is_nested(pa.list_(pa.int32()))
+    assert types.is_nested(pa.list_(pa.int32(), 3))
     assert types.is_nested(pa.large_list(pa.int32()))
     assert not types.is_nested(pa.int32())
 
diff --git a/python/pyarrow/types.py b/python/pyarrow/types.py
index 0f68ca9fe5..6c262b49cb 100644
--- a/python/pyarrow/types.py
+++ b/python/pyarrow/types.py
@@ -40,8 +40,8 @@ _TEMPORAL_TYPES = ({lib.Type_TIMESTAMP,
                     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_LARGE_LIST, lib.Type_STRUCT,
-                 lib.Type_MAP} | _UNION_TYPES
+_NESTED_TYPES = {lib.Type_LIST, lib.Type_FIXED_SIZE_LIST, lib.Type_LARGE_LIST,
+                 lib.Type_STRUCT, lib.Type_MAP} | _UNION_TYPES
 
 
 @doc(datatype="null")

Reply via email to