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 d519a4cb05 GH-40266: [Python] Mark ListView as a nested type (#40265)
d519a4cb05 is described below

commit d519a4cb05773dc6ef36e02c963b5e27c73d06e5
Author: Dane Pitkin <[email protected]>
AuthorDate: Wed Feb 28 04:37:34 2024 -0500

    GH-40266: [Python] Mark ListView as a nested type (#40265)
    
    ### Rationale for this change
    
    ListView types are nested, so `is_nested()` should return True.
    
    ### What changes are included in this PR?
    
    * `pa.types.is_nested(pa.list_view(<type>))` returns True
    
    ### Are these changes tested?
    
    Yes, unit tested.
    
    ### Are there any user-facing changes?
    
    Yes.
    * GitHub Issue: #40266
    
    Authored-by: Dane Pitkin <[email protected]>
    Signed-off-by: Joris Van den Bossche <[email protected]>
---
 python/pyarrow/tests/test_types.py | 2 ++
 python/pyarrow/types.py            | 1 +
 2 files changed, 3 insertions(+)

diff --git a/python/pyarrow/tests/test_types.py 
b/python/pyarrow/tests/test_types.py
index e048ed6fa5..a79702a8ca 100644
--- a/python/pyarrow/tests/test_types.py
+++ b/python/pyarrow/tests/test_types.py
@@ -216,6 +216,8 @@ def test_is_nested_or_struct():
     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 types.is_nested(pa.list_view(pa.int32()))
+    assert types.is_nested(pa.large_list_view(pa.int32()))
     assert not types.is_nested(pa.int32())
 
 
diff --git a/python/pyarrow/types.py b/python/pyarrow/types.py
index 6c262b49cb..66b1ec3395 100644
--- a/python/pyarrow/types.py
+++ b/python/pyarrow/types.py
@@ -41,6 +41,7 @@ _TEMPORAL_TYPES = ({lib.Type_TIMESTAMP,
                    _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} | _UNION_TYPES
 
 

Reply via email to