@@ -375,7 +375,7 @@ impl PySessionContext {
375375 None => {
376376 let state = self . ctx . state ( ) ;
377377 let schema = options. infer_schema ( & state, & table_path) ;
378- wait_for_future ( py, schema) ?
378+ wait_for_future ( py, schema) ??
379379 }
380380 } ;
381381 let config = ListingTableConfig :: new ( table_path)
@@ -400,7 +400,7 @@ impl PySessionContext {
400400 /// Returns a PyDataFrame whose plan corresponds to the SQL statement.
401401 pub fn sql ( & mut self , query : & str , py : Python ) -> PyDataFusionResult < PyDataFrame > {
402402 let result = self . ctx . sql ( query) ;
403- let df = wait_for_future ( py, result) ?;
403+ let df = wait_for_future ( py, result) ?? ;
404404 Ok ( PyDataFrame :: new ( df) )
405405 }
406406
@@ -417,7 +417,7 @@ impl PySessionContext {
417417 SQLOptions :: new ( )
418418 } ;
419419 let result = self . ctx . sql_with_options ( query, options) ;
420- let df = wait_for_future ( py, result) ?;
420+ let df = wait_for_future ( py, result) ?? ;
421421 Ok ( PyDataFrame :: new ( df) )
422422 }
423423
@@ -451,7 +451,7 @@ impl PySessionContext {
451451
452452 self . ctx . register_table ( & * table_name, Arc :: new ( table) ) ?;
453453
454- let table = wait_for_future ( py, self . _table ( & table_name) ) ?;
454+ let table = wait_for_future ( py, self . _table ( & table_name) ) ?? ;
455455
456456 let df = PyDataFrame :: new ( table) ;
457457 Ok ( df)
@@ -650,7 +650,7 @@ impl PySessionContext {
650650 . collect ( ) ;
651651
652652 let result = self . ctx . register_parquet ( name, path, options) ;
653- wait_for_future ( py, result) ?;
653+ wait_for_future ( py, result) ?? ;
654654 Ok ( ( ) )
655655 }
656656
@@ -693,11 +693,11 @@ impl PySessionContext {
693693 if path. is_instance_of :: < PyList > ( ) {
694694 let paths = path. extract :: < Vec < String > > ( ) ?;
695695 let result = self . register_csv_from_multiple_paths ( name, paths, options) ;
696- wait_for_future ( py, result) ?;
696+ wait_for_future ( py, result) ?? ;
697697 } else {
698698 let path = path. extract :: < String > ( ) ?;
699699 let result = self . ctx . register_csv ( name, & path, options) ;
700- wait_for_future ( py, result) ?;
700+ wait_for_future ( py, result) ?? ;
701701 }
702702
703703 Ok ( ( ) )
@@ -734,7 +734,7 @@ impl PySessionContext {
734734 options. schema = schema. as_ref ( ) . map ( |x| & x. 0 ) ;
735735
736736 let result = self . ctx . register_json ( name, path, options) ;
737- wait_for_future ( py, result) ?;
737+ wait_for_future ( py, result) ?? ;
738738
739739 Ok ( ( ) )
740740 }
@@ -764,7 +764,7 @@ impl PySessionContext {
764764 options. schema = schema. as_ref ( ) . map ( |x| & x. 0 ) ;
765765
766766 let result = self . ctx . register_avro ( name, path, options) ;
767- wait_for_future ( py, result) ?;
767+ wait_for_future ( py, result) ?? ;
768768
769769 Ok ( ( ) )
770770 }
@@ -826,7 +826,8 @@ impl PySessionContext {
826826
827827 pub fn table ( & self , name : & str , py : Python ) -> PyResult < PyDataFrame > {
828828 let x = wait_for_future ( py, self . ctx . table ( name) )
829- . map_err ( |e| PyKeyError :: new_err ( e. to_string ( ) ) ) ?;
829+ . map_err ( |e| PyKeyError :: new_err ( e. to_string ( ) ) ) ?
830+ . map_err ( py_datafusion_err) ?;
830831 Ok ( PyDataFrame :: new ( x) )
831832 }
832833
@@ -865,10 +866,10 @@ impl PySessionContext {
865866 let df = if let Some ( schema) = schema {
866867 options. schema = Some ( & schema. 0 ) ;
867868 let result = self . ctx . read_json ( path, options) ;
868- wait_for_future ( py, result) ?
869+ wait_for_future ( py, result) ??
869870 } else {
870871 let result = self . ctx . read_json ( path, options) ;
871- wait_for_future ( py, result) ?
872+ wait_for_future ( py, result) ??
872873 } ;
873874 Ok ( PyDataFrame :: new ( df) )
874875 }
@@ -915,12 +916,12 @@ impl PySessionContext {
915916 let paths = path. extract :: < Vec < String > > ( ) ?;
916917 let paths = paths. iter ( ) . map ( |p| p as & str ) . collect :: < Vec < & str > > ( ) ;
917918 let result = self . ctx . read_csv ( paths, options) ;
918- let df = PyDataFrame :: new ( wait_for_future ( py, result) ?) ;
919+ let df = PyDataFrame :: new ( wait_for_future ( py, result) ?? ) ;
919920 Ok ( df)
920921 } else {
921922 let path = path. extract :: < String > ( ) ?;
922923 let result = self . ctx . read_csv ( path, options) ;
923- let df = PyDataFrame :: new ( wait_for_future ( py, result) ?) ;
924+ let df = PyDataFrame :: new ( wait_for_future ( py, result) ?? ) ;
924925 Ok ( df)
925926 }
926927 }
@@ -958,7 +959,7 @@ impl PySessionContext {
958959 . collect ( ) ;
959960
960961 let result = self . ctx . read_parquet ( path, options) ;
961- let df = PyDataFrame :: new ( wait_for_future ( py, result) ?) ;
962+ let df = PyDataFrame :: new ( wait_for_future ( py, result) ?? ) ;
962963 Ok ( df)
963964 }
964965
@@ -978,10 +979,10 @@ impl PySessionContext {
978979 let df = if let Some ( schema) = schema {
979980 options. schema = Some ( & schema. 0 ) ;
980981 let read_future = self . ctx . read_avro ( path, options) ;
981- wait_for_future ( py, read_future) ?
982+ wait_for_future ( py, read_future) ??
982983 } else {
983984 let read_future = self . ctx . read_avro ( path, options) ;
984- wait_for_future ( py, read_future) ?
985+ wait_for_future ( py, read_future) ??
985986 } ;
986987 Ok ( PyDataFrame :: new ( df) )
987988 }
@@ -1021,8 +1022,8 @@ impl PySessionContext {
10211022 let plan = plan. plan . clone ( ) ;
10221023 let fut: JoinHandle < datafusion:: common:: Result < SendableRecordBatchStream > > =
10231024 rt. spawn ( async move { plan. execute ( part, Arc :: new ( ctx) ) } ) ;
1024- let stream = wait_for_future ( py, fut) . map_err ( py_datafusion_err ) ?;
1025- Ok ( PyRecordBatchStream :: new ( stream? ) )
1025+ let stream = wait_for_future ( py, async { fut. await . expect ( "Tokio task panicked" ) } ) ? ?;
1026+ Ok ( PyRecordBatchStream :: new ( stream) )
10261027 }
10271028}
10281029
0 commit comments