@@ -43,7 +43,7 @@ use pyo3::types::{PyCapsule, PyList, PyTuple, PyTupleMethods};
4343use tokio:: task:: JoinHandle ;
4444
4545use crate :: catalog:: PyTable ;
46- use crate :: errors:: { py_datafusion_err, PyDataFusionError } ;
46+ use crate :: errors:: { py_datafusion_err, to_datafusion_err , PyDataFusionError } ;
4747use crate :: expr:: sort_expr:: to_sort_expressions;
4848use crate :: physical_plan:: PyExecutionPlan ;
4949use crate :: record_batch:: PyRecordBatchStream ;
@@ -753,7 +753,7 @@ impl PyDataFrame {
753753 let df = self . df . as_ref ( ) . clone ( ) ;
754754 let fut: JoinHandle < datafusion:: common:: Result < SendableRecordBatchStream > > =
755755 rt. spawn ( async move { df. execute_stream ( ) . await } ) ;
756- let stream = wait_for_future ( py, async { fut. await . expect ( "Tokio task panicked" ) } ) ??;
756+ let stream = wait_for_future ( py, async { fut. await . map_err ( to_datafusion_err ) } ) ??;
757757 Ok ( PyRecordBatchStream :: new ( stream) )
758758 }
759759
@@ -763,7 +763,7 @@ impl PyDataFrame {
763763 let df = self . df . as_ref ( ) . clone ( ) ;
764764 let fut: JoinHandle < datafusion:: common:: Result < Vec < SendableRecordBatchStream > > > =
765765 rt. spawn ( async move { df. execute_stream_partitioned ( ) . await } ) ;
766- let stream = wait_for_future ( py, async { fut. await . expect ( "Tokio task panicked" ) } ) ?
766+ let stream = wait_for_future ( py, async { fut. await . map_err ( to_datafusion_err ) } ) ?
767767 . map_err ( py_datafusion_err) ?;
768768
769769 Ok ( stream. into_iter ( ) . map ( PyRecordBatchStream :: new) . collect ( ) )
0 commit comments