From 64373a797614da2f460c9c8db051fcbf472b5144 Mon Sep 17 00:00:00 2001 From: Enrico Minack Date: Thu, 26 Sep 2024 10:51:20 +0200 Subject: [PATCH] Align buffers in RecordBatch.from_pyarrow_bound --- arrow/src/pyarrow.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/arrow/src/pyarrow.rs b/arrow/src/pyarrow.rs index b05c967d7d9b..2532bafbe3c6 100644 --- a/arrow/src/pyarrow.rs +++ b/arrow/src/pyarrow.rs @@ -363,13 +363,14 @@ impl FromPyArrow for RecordBatch { let schema_ptr = unsafe { schema_capsule.reference::() }; let ffi_array = unsafe { FFI_ArrowArray::from_raw(array_capsule.pointer().cast()) }; - let array_data = unsafe { ffi::from_ffi(ffi_array, schema_ptr) }.map_err(to_py_err)?; + let mut array_data = unsafe { ffi::from_ffi(ffi_array, schema_ptr) }.map_err(to_py_err)?; if !matches!(array_data.data_type(), DataType::Struct(_)) { return Err(PyTypeError::new_err( "Expected Struct type from __arrow_c_array.", )); } let options = RecordBatchOptions::default().with_row_count(Some(array_data.len())); + array_data.align_buffers(); let array = StructArray::from(array_data); // StructArray does not embed metadata from schema. We need to override // the output schema with the schema from the capsule.