tustvold commented on code in PR #4806:
URL: https://github.com/apache/arrow-rs/pull/4806#discussion_r1328073026


##########
arrow/src/pyarrow.rs:
##########
@@ -270,25 +270,13 @@ impl FromPyArrow for RecordBatch {
 
 impl ToPyArrow for RecordBatch {
     fn to_pyarrow(&self, py: Python) -> PyResult<PyObject> {
-        let mut py_arrays = vec![];
-
-        let schema = self.schema();
-        let columns = self.columns().iter();
-
-        for array in columns {
-            py_arrays.push(array.to_data().to_pyarrow(py)?);
-        }
-
-        let py_schema = schema.to_pyarrow(py)?;
-
-        let module = py.import("pyarrow")?;
-        let class = module.getattr("RecordBatch")?;
-        let args = (py_arrays,);
-        let kwargs = PyDict::new(py);
-        kwargs.set_item("schema", py_schema)?;
-        let record = class.call_method("from_arrays", args, Some(kwargs))?;
-
-        Ok(PyObject::from(record))
+        // arrow::ffi is implemented for Arrays not RecordBatches, so the next
+        // best thing is to wrap it in a RecordBatchIterator and export that.

Review Comment:
   ```suggestion
           // Workaround apache/arrow#37669 by returning RecordBatchIterator
   ```



-- 
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