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

AlenkaF 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 e778b2a6117 GH-48182: [Python] Add regression test for 
RecordBatch.from_struct_array with list offsets (#49162)
e778b2a6117 is described below

commit e778b2a6117aaac2e88acec682326b5b4f91a096
Author: Gnananjali <[email protected]>
AuthorDate: Wed Nov 4 16:55:55 2026 +0530

    GH-48182: [Python] Add regression test for RecordBatch.from_struct_array 
with list offsets (#49162)
    
    Adds a regression test to ensure RecordBatch.from_struct_array correctly 
handles sliced StructArray with offsets.
    
    This test verifies that only the sliced rows are included when converting a 
StructArray to RecordBatch.
    
    This addresses GH-48182.
    
    * GitHub Issue: #48182
    
    Authored-by: Gnananjali <[email protected]>
    Signed-off-by: AlenkaF <[email protected]>
---
 python/pyarrow/tests/test_table.py | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/python/pyarrow/tests/test_table.py 
b/python/pyarrow/tests/test_table.py
index b1af245be4b..0fefabf02ab 100644
--- a/python/pyarrow/tests/test_table.py
+++ b/python/pyarrow/tests/test_table.py
@@ -894,6 +894,23 @@ def test_recordbatch_from_struct_array():
     ))
 
 
+def test_recordbatch_from_struct_array_with_list_offsets():
+    struct_type = pa.struct([("x", pa.int64()), ("y", pa.int64())])
+
+    list0 = [{"x": 1, "y": 2}, {"x": 3, "y": 4}]
+    list1 = [{"x": 5, "y": 6}]
+    list2 = [{"x": 7, "y": 8}, {"x": 9, "y": 10}]
+
+    arr = pa.array([list0, list1, list2], type=pa.list_(struct_type))
+
+    elem0 = arr[0]
+    batch = pa.RecordBatch.from_struct_array(elem0.values)
+
+    assert len(batch) == 2
+    assert batch.column("x").to_pylist() == [1, 3]
+    assert batch.column("y").to_pylist() == [2, 4]
+
+
 def test_recordbatch_to_struct_array():
     batch = pa.RecordBatch.from_arrays(
         [

Reply via email to