@@ -48,7 +48,7 @@ use crate::catalog::PyTable;
4848use crate :: errors:: { py_datafusion_err, PyDataFusionError } ;
4949use crate :: expr:: sort_expr:: to_sort_expressions;
5050use crate :: physical_plan:: PyExecutionPlan ;
51- use crate :: record_batch:: PyRecordBatchStream ;
51+ use crate :: record_batch:: { poll_next_batch , PyRecordBatchStream } ;
5252use crate :: sql:: logical:: PyLogicalPlan ;
5353use crate :: utils:: {
5454 get_tokio_runtime, is_ipython_env, py_obj_to_scalar_value, spawn_stream, spawn_streams,
@@ -390,11 +390,11 @@ impl Iterator for DataFrameStreamReader {
390390 // respecting Python signal handling (e.g. ``KeyboardInterrupt``).
391391 // This mirrors the behaviour of other synchronous wrappers and
392392 // prevents blocking indefinitely when a Python interrupt is raised.
393- let fut = self . stream . next ( ) ;
393+ let fut = poll_next_batch ( & mut self . stream ) ;
394394 let result = Python :: with_gil ( |py| wait_for_future ( py, fut) ) ;
395395
396396 match result {
397- Ok ( Some ( Ok ( batch) ) ) => {
397+ Ok ( Ok ( Some ( batch) ) ) => {
398398 let batch = if let Some ( ref schema) = self . projection {
399399 match record_batch_into_schema ( batch, schema. as_ref ( ) ) {
400400 Ok ( b) => b,
@@ -405,8 +405,8 @@ impl Iterator for DataFrameStreamReader {
405405 } ;
406406 Some ( Ok ( batch) )
407407 }
408- Ok ( Some ( Err ( e ) ) ) => Some ( Err ( ArrowError :: ExternalError ( Box :: new ( e ) ) ) ) ,
409- Ok ( None ) => None ,
408+ Ok ( Ok ( None ) ) => None ,
409+ Ok ( Err ( e ) ) => Some ( Err ( ArrowError :: ExternalError ( Box :: new ( e ) ) ) ) ,
410410 Err ( e) => Some ( Err ( ArrowError :: ExternalError ( Box :: new ( e) ) ) ) ,
411411 }
412412 }
0 commit comments