File tree 1 file changed +7
-1
lines changed
1 file changed +7
-1
lines changed Original file line number Diff line number Diff line change @@ -363,13 +363,19 @@ impl FromPyArrow for RecordBatch {
363
363
364
364
let schema_ptr = unsafe { schema_capsule. reference :: < FFI_ArrowSchema > ( ) } ;
365
365
let ffi_array = unsafe { FFI_ArrowArray :: from_raw ( array_capsule. pointer ( ) . cast ( ) ) } ;
366
- let array_data = unsafe { ffi:: from_ffi ( ffi_array, schema_ptr) } . map_err ( to_py_err) ?;
366
+ let mut array_data =
367
+ unsafe { ffi:: from_ffi ( ffi_array, schema_ptr) } . map_err ( to_py_err) ?;
367
368
if !matches ! ( array_data. data_type( ) , DataType :: Struct ( _) ) {
368
369
return Err ( PyTypeError :: new_err (
369
370
"Expected Struct type from __arrow_c_array." ,
370
371
) ) ;
371
372
}
372
373
let options = RecordBatchOptions :: default ( ) . with_row_count ( Some ( array_data. len ( ) ) ) ;
374
+ // Ensure data is aligned (by potentially copying the buffers).
375
+ // This is needed because some python code (for example the
376
+ // python flight client) produces unaligned buffers
377
+ // See https://github.com/apache/arrow/issues/43552 for details
378
+ array_data. align_buffers ( ) ;
373
379
let array = StructArray :: from ( array_data) ;
374
380
// StructArray does not embed metadata from schema. We need to override
375
381
// the output schema with the schema from the capsule.
You can’t perform that action at this time.
0 commit comments