Skip to content

Commit

Permalink
Update arrow/src/pyarrow.rs
Browse files Browse the repository at this point in the history
Co-authored-by: Raphael Taylor-Davies <[email protected]>
  • Loading branch information
kylebarron and tustvold authored Nov 15, 2023
1 parent 107acef commit 6c44e01
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions arrow/src/pyarrow.rs
Original file line number Diff line number Diff line change
Expand Up @@ -351,15 +351,12 @@ impl FromPyArrow for RecordBatch {
let array_ptr = array_capsule.pointer() as *mut FFI_ArrowArray;
let ffi_array = unsafe { std::ptr::replace(array_ptr, FFI_ArrowArray::empty()) };
let array_data = ffi::from_ffi(ffi_array, schema_ptr).map_err(to_py_err)?;
let array_ref = make_array(array_data);

if !matches!(array_ref.data_type(), DataType::Struct(_)) {
if !matches!(array_data.data_type(), DataType::Struct(_)) {
return Err(PyTypeError::new_err(
"Expected Struct type from __arrow_c_array.",
));
}

let array = array_ref.as_any().downcast_ref::<StructArray>().unwrap();
let array = StructArray::from(array_data);
return Ok(array.into());
}

Expand Down

0 comments on commit 6c44e01

Please sign in to comment.