Rich-T-kid commented on code in PR #10894:
URL: https://github.com/apache/arrow-rs/pull/10894#discussion_r4107145564


##########
arrow-pyarrow/src/lib.rs:
##########
@@ -403,63 +434,73 @@ impl<T: ToPyArrow> ToPyArrow for Vec<T> {
     }
 }
 
+fn record_batch_from_pyarrow_bound_impl(
+    value: &Bound<PyAny>,
+    array_data_from_pyarrow: impl Fn(&Bound<PyAny>) -> PyResult<ArrayData>,
+) -> PyResult<RecordBatch> {
+    // Newer versions of PyArrow as well as other libraries with Arrow data 
implement this
+    // method, so prefer it over _export_to_c.
+    // See 
https://arrow.apache.org/docs/format/CDataInterface/PyCapsuleInterface.html
+    if let Some((schema_capsule, array_capsule)) = 
call_arrow_c_array_method_if_exists(value)? {
+        let schema_ptr = extract_capsule(&schema_capsule, c"arrow_schema", 
"__arrow_c_array__")?;
+        let array_ptr = extract_capsule(&array_capsule, c"arrow_array", 
"__arrow_c_array__")?;
+        let ffi_array = unsafe { FFI_ArrowArray::from_raw(array_ptr.as_ptr()) 
};
+        let array_data =

Review Comment:
   good idea, in 
https://github.com/apache/arrow-rs/pull/10894/commits/7a27a18a6d6b76b5a76760a51801d0f83fc977eb
 we always call the unsafe method and then validate depending on the flag



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to