@@ -1454,6 +1454,25 @@ def test_set_flat_field_keep_dtype_raises_for_new_field():
14541454 ext_array .set_flat_field ("c" , [True , False , True , False , True , False , True ], keep_dtype = False )
14551455
14561456
1457+ def test_set_flat_field_chunked_values ():
1458+ """Tests that set_flat_field works fine with input value which is chunked"""
1459+ struct_array = pa .StructArray .from_arrays (
1460+ arrays = [
1461+ pa .array ([np .array ([1.0 , 2.0 , 3.0 ]), np .array ([1.0 , 2.0 , 3.0 , 4.0 ])]),
1462+ pa .array ([- np .array ([4.0 , 5.0 , 6.0 ]), - np .array ([3.0 , 4.0 , 5.0 , 6.0 ])]),
1463+ ],
1464+ names = ["a" , "b" ],
1465+ )
1466+ ext_array = NestedExtensionArray (struct_array )
1467+
1468+ new_chunked_values = pa .chunked_array ([["x" , "y" , "z" ], ["x1" , "x2" , "x3" , "x4" ]])
1469+ assert new_chunked_values .num_chunks > 1
1470+ new_series = pd .Series (new_chunked_values , dtype = pd .ArrowDtype (new_chunked_values .type ))
1471+
1472+ # Previously failed for series with chunked array
1473+ ext_array .set_flat_field ("c" , new_series )
1474+
1475+
14571476def test_set_list_field_new_field ():
14581477 """Tests setting a new field with a new "list" array"""
14591478 struct_array = pa .StructArray .from_arrays (
0 commit comments