@@ -309,11 +309,11 @@ impl PyDataFrame {
309309
310310 let table_uuid = uuid:: Uuid :: new_v4 ( ) . to_string ( ) ;
311311
312- // Convert record batches to PyObject list
312+ // Convert record batches to PyAny list
313313 let py_batches = batches
314314 . iter ( )
315315 . map ( |rb| rb. to_pyarrow ( py) )
316- . collect :: < PyResult < Vec < PyObject > > > ( ) ?;
316+ . collect :: < PyResult < Vec < _ > > > ( ) ?;
317317
318318 let py_schema = self . schema ( ) . into_pyobject ( py) ?;
319319
@@ -523,7 +523,7 @@ impl PyDataFrame {
523523 /// Executes the plan, returning a list of `RecordBatch`es.
524524 /// Unless some order is specified in the plan, there is no
525525 /// guarantee of the order of the result.
526- fn collect ( & self , py : Python ) -> PyResult < Vec < PyObject > > {
526+ fn collect < ' py > ( & self , py : Python < ' py > ) -> PyResult < Vec < Bound < ' py , PyAny > > > {
527527 let batches = wait_for_future ( py, self . df . as_ref ( ) . clone ( ) . collect ( ) ) ?
528528 . map_err ( PyDataFusionError :: from) ?;
529529 // cannot use PyResult<Vec<RecordBatch>> return type due to
@@ -539,7 +539,7 @@ impl PyDataFrame {
539539
540540 /// Executes this DataFrame and collects all results into a vector of vector of RecordBatch
541541 /// maintaining the input partitioning.
542- fn collect_partitioned ( & self , py : Python ) -> PyResult < Vec < Vec < PyObject > > > {
542+ fn collect_partitioned < ' py > ( & self , py : Python < ' py > ) -> PyResult < Vec < Vec < Bound < ' py , PyAny > > > > {
543543 let batches = wait_for_future ( py, self . df . as_ref ( ) . clone ( ) . collect_partitioned ( ) ) ?
544544 . map_err ( PyDataFusionError :: from) ?;
545545
@@ -907,15 +907,14 @@ impl PyDataFrame {
907907
908908 /// Convert to Arrow Table
909909 /// Collect the batches and pass to Arrow Table
910- fn to_arrow_table ( & self , py : Python < ' _ > ) -> PyResult < PyObject > {
910+ fn to_arrow_table < ' py > ( & self , py : Python < ' py > ) -> PyResult < Bound < ' py , PyAny > > {
911911 let batches = self . collect ( py) ?. into_pyobject ( py) ?;
912912 let schema = self . schema ( ) . into_pyobject ( py) ?;
913913
914914 // Instantiate pyarrow Table object and use its from_batches method
915915 let table_class = py. import ( "pyarrow" ) ?. getattr ( "Table" ) ?;
916916 let args = PyTuple :: new ( py, & [ batches, schema] ) ?;
917- let table: PyObject = table_class. call_method1 ( "from_batches" , args) ?. into ( ) ;
918- Ok ( table)
917+ table_class. call_method1 ( "from_batches" , args)
919918 }
920919
921920 #[ pyo3( signature = ( requested_schema=None ) ) ]
@@ -976,42 +975,38 @@ impl PyDataFrame {
976975
977976 /// Convert to pandas dataframe with pyarrow
978977 /// Collect the batches, pass to Arrow Table & then convert to Pandas DataFrame
979- fn to_pandas ( & self , py : Python < ' _ > ) -> PyResult < PyObject > {
978+ fn to_pandas < ' py > ( & self , py : Python < ' py > ) -> PyResult < Bound < ' py , PyAny > > {
980979 let table = self . to_arrow_table ( py) ?;
981980
982981 // See also: https://arrow.apache.org/docs/python/generated/pyarrow.Table.html#pyarrow.Table.to_pandas
983- let result = table. call_method0 ( py, "to_pandas" ) ?;
984- Ok ( result)
982+ table. call_method0 ( "to_pandas" )
985983 }
986984
987985 /// Convert to Python list using pyarrow
988986 /// Each list item represents one row encoded as dictionary
989- fn to_pylist ( & self , py : Python < ' _ > ) -> PyResult < PyObject > {
987+ fn to_pylist < ' py > ( & self , py : Python < ' py > ) -> PyResult < Bound < ' py , PyAny > > {
990988 let table = self . to_arrow_table ( py) ?;
991989
992990 // See also: https://arrow.apache.org/docs/python/generated/pyarrow.Table.html#pyarrow.Table.to_pylist
993- let result = table. call_method0 ( py, "to_pylist" ) ?;
994- Ok ( result)
991+ table. call_method0 ( "to_pylist" )
995992 }
996993
997994 /// Convert to Python dictionary using pyarrow
998995 /// Each dictionary key is a column and the dictionary value represents the column values
999- fn to_pydict ( & self , py : Python ) -> PyResult < PyObject > {
996+ fn to_pydict < ' py > ( & self , py : Python < ' py > ) -> PyResult < Bound < ' py , PyAny > > {
1000997 let table = self . to_arrow_table ( py) ?;
1001998
1002999 // See also: https://arrow.apache.org/docs/python/generated/pyarrow.Table.html#pyarrow.Table.to_pydict
1003- let result = table. call_method0 ( py, "to_pydict" ) ?;
1004- Ok ( result)
1000+ table. call_method0 ( "to_pydict" )
10051001 }
10061002
10071003 /// Convert to polars dataframe with pyarrow
10081004 /// Collect the batches, pass to Arrow Table & then convert to polars DataFrame
1009- fn to_polars ( & self , py : Python < ' _ > ) -> PyResult < PyObject > {
1005+ fn to_polars < ' py > ( & self , py : Python < ' py > ) -> PyResult < Bound < ' py , PyAny > > {
10101006 let table = self . to_arrow_table ( py) ?;
10111007 let dataframe = py. import ( "polars" ) ?. getattr ( "DataFrame" ) ?;
10121008 let args = PyTuple :: new ( py, & [ table] ) ?;
1013- let result: PyObject = dataframe. call1 ( args) ?. into ( ) ;
1014- Ok ( result)
1009+ dataframe. call1 ( args)
10151010 }
10161011
10171012 // Executes this DataFrame to get the total number of rows.
@@ -1023,7 +1018,7 @@ impl PyDataFrame {
10231018 #[ pyo3( signature = ( value, columns=None ) ) ]
10241019 fn fill_null (
10251020 & self ,
1026- value : PyObject ,
1021+ value : Bound < PyAny > ,
10271022 columns : Option < Vec < PyBackedStr > > ,
10281023 py : Python ,
10291024 ) -> PyDataFusionResult < Self > {
0 commit comments