Copilot commented on code in PR #58:
URL: https://github.com/apache/fluss-rust/pull/58#discussion_r2554516224


##########
bindings/python/src/utils.rs:
##########
@@ -172,13 +171,21 @@ impl Utils {
     pub fn combine_batches_to_table(
         py: Python,
         batches: Vec<Arc<arrow::record_batch::RecordBatch>>,
-    ) -> PyResult<PyObject> {
-        // Convert Rust Arrow RecordBatch to PyObject
-        let py_batches: Result<Vec<PyObject>, _> = batches
+    ) -> PyResult<Py<PyAny>> {
+        use arrow_array::RecordBatch as ArrowArrayRecordBatch;
+        
+        let py_batches: Result<Vec<Py<PyAny>>, _> = batches
             .iter()
             .map(|batch| {
-                batch.as_ref().to_pyarrow(py).map_err(|e| {
-                    FlussError::new_err(format!("Failed to convert RecordBatch 
to PyObject: {e}"))
+                ArrowArrayRecordBatch::try_new(
+                    batch.schema().clone(),
+                    batch.columns().to_vec(),
+                )
+                .map_err(|e| FlussError::new_err(format!("Failed to convert 
RecordBatch: {e}")))
+                .and_then(|b| {
+                    ToPyArrow::to_pyarrow(&b, py)
+                        .map(|x| x.into())
+                        .map_err(|e| FlussError::new_err(format!("Failed to 
convert to PyObject: {e}")))

Review Comment:
   The error message still refers to "PyObject" but the code now returns 
`Py<PyAny>`. Update the error message to "Failed to convert to Py<PyAny>" or a 
more generic "Failed to convert to Python object" for consistency with the code 
changes.
   ```suggestion
                           .map_err(|e| FlussError::new_err(format!("Failed to 
convert to Py<PyAny>: {e}")))
   ```



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