@@ -62,9 +62,9 @@ impl PyTableProvider {
6262 Self { provider }
6363 }
6464
65- pub fn as_table ( & self ) -> PyDataFusionResult < PyTable > {
65+ pub fn as_table ( & self ) -> PyTable {
6666 let table_provider: Arc < dyn TableProvider > = self . provider . clone ( ) ;
67- Ok ( PyTable :: new ( table_provider) )
67+ PyTable :: new ( table_provider)
6868 }
6969}
7070
@@ -107,17 +107,6 @@ impl PyDataFrame {
107107 }
108108 }
109109
110- /// Convert this DataFrame into a Table that can be used in register_table
111- fn into_view ( & self ) -> PyDataFusionResult < PyTable > {
112- // Call the underlying Rust DataFrame::into_view method.
113- // Note that the Rust method consumes self; here we clone the inner Arc<DataFrame>
114- // so that we don’t invalidate this PyDataFrame.
115- let table_provider = self . df . as_ref ( ) . clone ( ) . into_view ( ) ;
116- let table_provider = PyTableProvider :: new ( table_provider) ;
117-
118- Ok ( table_provider. as_table ( ) ?)
119- }
120-
121110 fn __repr__ ( & self , py : Python ) -> PyDataFusionResult < String > {
122111 let df = self . df . as_ref ( ) . clone ( ) . limit ( 0 , Some ( 10 ) ) ?;
123112 let batches = wait_for_future ( py, df. collect ( ) ) ?;
@@ -185,6 +174,20 @@ impl PyDataFrame {
185174 PyArrowType ( self . df . schema ( ) . into ( ) )
186175 }
187176
177+ /// Convert this DataFrame into a Table that can be used in register_table
178+ fn _into_view ( & self ) -> PyDataFusionResult < PyTable > {
179+ // Call the underlying Rust DataFrame::into_view method.
180+ // Note that the Rust method consumes self; here we clone the inner Arc<DataFrame>
181+ // so that we don’t invalidate this PyDataFrame.
182+ // _into_view because clippy says `into_*` usually take `self` by value
183+ // but we cannot own self because Python objects are shared,
184+ // so 'self' cannot be moved out of the Python interpreter
185+ let table_provider = self . df . as_ref ( ) . clone ( ) . into_view ( ) ;
186+ let table_provider = PyTableProvider :: new ( table_provider) ;
187+
188+ Ok ( table_provider. as_table ( ) )
189+ }
190+
188191 #[ pyo3( signature = ( * args) ) ]
189192 fn select_columns ( & self , args : Vec < PyBackedStr > ) -> PyDataFusionResult < Self > {
190193 let args = args. iter ( ) . map ( |s| s. as_ref ( ) ) . collect :: < Vec < & str > > ( ) ;
0 commit comments