jorisvandenbossche commented on code in PR #13894:
URL: https://github.com/apache/arrow/pull/13894#discussion_r955917621


##########
python/pyarrow/tests/test_array.py:
##########
@@ -919,6 +919,53 @@ def test_list_from_arrays(list_array_type, 
list_type_factory):
         list_array_type.from_arrays(offsets, values, type=typ)
 
 
[email protected](('list_array_type', 'list_type_factory'), (
+    (pa.ListArray, pa.list_),
+    (pa.LargeListArray, pa.large_list)
+))
[email protected]("arr", (
+    [None, [0]],
+    [None, [0, None], [0]],
+    [[0], [1]],
+))
+def test_list_array_types_from_arrays(
+    list_array_type, list_type_factory, arr
+):
+    arr = pa.array(arr, list_type_factory(pa.int8()))
+    reconstructed_arr = list_array_type.from_arrays(
+        arr.offsets, arr.values, mask=arr.is_null())
+    assert arr == reconstructed_arr

Review Comment:
   It seems that the `values` is not sliced:
   
   ```
   In [88]: arr = pa.array([[0], None, [0, None], [0]], pa.list_(pa.int8()))
   
   In [89]: arr2 = arr[1:]
   
   In [90]: arr
   Out[90]: 
   <pyarrow.lib.ListArray object at 0x7f34394a1100>
   [
     [
       0
     ],
     null,
     [
       0,
       null
     ],
     [
       0
     ]
   ]
   
   In [91]: arr2
   Out[91]: 
   <pyarrow.lib.ListArray object at 0x7f34394a1dc0>
   [
     null,
     [
       0,
       null
     ],
     [
       0
     ]
   ]
   
   In [92]: arr.values
   Out[92]: 
   <pyarrow.lib.Int8Array object at 0x7f34394a1e20>
   [
     0,
     0,
     null,
     0
   ]
   
   In [94]: arr2.values
   Out[94]: 
   <pyarrow.lib.Int8Array object at 0x7f342a668d60>
   [
     0,
     0,
     null,
     0
   ]
   
   In [95]: arr.offsets
   Out[95]: 
   <pyarrow.lib.Int32Array object at 0x7f34394a1880>
   [
     0,
     1,
     1,
     3,
     4
   ]
   
   In [96]: arr2.offsets
   Out[96]: 
   <pyarrow.lib.Int32Array object at 0x7f34394a1b20>
   [
     1,
     1,
     3,
     4
   ]
   ```
   
   while the offsets are sliced.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to