Skip to content

Commit ccb4a5c

Browse files
committed
add comment to clarify error handling in next method of PyRecordBatchStream
1 parent c3d808c commit ccb4a5c

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/record_batch.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,13 @@ impl PyRecordBatchStream {
6363
impl PyRecordBatchStream {
6464
fn next(&mut self, py: Python) -> PyResult<PyRecordBatch> {
6565
let stream = self.stream.clone();
66-
wait_for_future(py, next_stream(stream, true))?
66+
// Two-step error handling process:
67+
// 1. First ? handles errors from the async runtime/future execution
68+
let item = wait_for_future(py, next_stream(stream, true))?;
69+
// 2. Second ? converts and propagates any DataFusion errors to Python errors
70+
let batch = item.map_err(PyDataFusionError::from)?;
71+
Ok(batch)
6772
}
68-
6973
fn __next__(&mut self, py: Python) -> PyResult<PyRecordBatch> {
7074
self.next(py)
7175
}

0 commit comments

Comments
 (0)