@@ -19,27 +19,23 @@ use std::any::Any;
1919use std:: ffi:: c_void;
2020use std:: sync:: Arc ;
2121
22- use abi_stable:: StableAbi ;
23- use abi_stable:: std_types:: { RResult , RVec } ;
24- use datafusion_catalog:: { TableFunctionArgs , TableFunctionImpl , TableProvider } ;
25- use datafusion_common:: DataFusionError ;
22+ use datafusion_catalog:: { TableFunctionImpl , TableProvider } ;
2623use datafusion_common:: error:: Result ;
2724use datafusion_execution:: TaskContext ;
25+ use datafusion_expr:: Expr ;
2826use datafusion_proto:: logical_plan:: from_proto:: parse_exprs;
2927use datafusion_proto:: logical_plan:: to_proto:: serialize_exprs;
3028use datafusion_proto:: logical_plan:: {
3129 DefaultLogicalExtensionCodec , LogicalExtensionCodec ,
3230} ;
3331use datafusion_proto:: protobuf:: LogicalExprList ;
34- use datafusion_session:: Session ;
3532use prost:: Message ;
3633
3734use stabby:: vec:: Vec as SVec ;
3835use tokio:: runtime:: Handle ;
3936
4037use crate :: execution:: FFI_TaskContextProvider ;
4138use crate :: proto:: logical_extension_codec:: FFI_LogicalExtensionCodec ;
42- use crate :: session:: { FFI_SessionRef , ForeignSession } ;
4339use crate :: table_provider:: FFI_TableProvider ;
4440use crate :: util:: { FFI_Result , FFIResult } ;
4541use crate :: { df_result, sresult_return} ;
@@ -48,22 +44,11 @@ use crate::{df_result, sresult_return};
4844#[ repr( C ) ]
4945#[ derive( Debug ) ]
5046pub struct FFI_TableFunction {
51- /// Equivalent to the [`TableFunctionImpl:: call`] .
47+ /// Equivalent to the ` call` function of the TableFunctionImpl .
5248 /// The arguments are Expr passed as protobuf encoded bytes.
53- #[ deprecated(
54- since = "53.0.0" ,
55- note = "See TableFunctionImpl::call deprecation note"
56- ) ]
5749 pub call :
5850 unsafe extern "C" fn ( udtf : & Self , args : SVec < u8 > ) -> FFIResult < FFI_TableProvider > ,
5951
60- /// Equivalent to the [`TableFunctionImpl::call_with_args`].
61- call_with_args : unsafe extern "C" fn (
62- udtf : & Self ,
63- args : RVec < u8 > ,
64- session : FFI_SessionRef ,
65- ) -> FFIResult < FFI_TableProvider > ,
66-
6752 pub logical_codec : FFI_LogicalExtensionCodec ,
6853
6954 /// Used to create a clone on the provider of the udtf. This should
@@ -131,47 +116,6 @@ unsafe extern "C" fn call_fn_wrapper(
131116 ) )
132117}
133118
134- unsafe extern "C" fn call_with_args_wrapper (
135- udtf : & FFI_TableFunction ,
136- args : RVec < u8 > ,
137- session : FFI_SessionRef ,
138- ) -> FFIResult < FFI_TableProvider > {
139- let runtime = udtf. runtime ( ) ;
140- let udtf_inner = udtf. inner ( ) ;
141-
142- let ctx: Arc < TaskContext > =
143- rresult_return ! ( ( & udtf. logical_codec. task_ctx_provider) . try_into( ) ) ;
144- let codec: Arc < dyn LogicalExtensionCodec > = ( & udtf. logical_codec ) . into ( ) ;
145-
146- let proto_filters = rresult_return ! ( LogicalExprList :: decode( args. as_ref( ) ) ) ;
147-
148- let args = rresult_return ! ( parse_exprs(
149- proto_filters. expr. iter( ) ,
150- ctx. as_ref( ) ,
151- codec. as_ref( )
152- ) ) ;
153-
154- let mut foreign_session = None ;
155- let session = rresult_return ! (
156- session
157- . as_local( )
158- . map( Ok :: <& ( dyn Session + Send + Sync ) , DataFusionError >)
159- . unwrap_or_else( || {
160- foreign_session = Some ( ForeignSession :: try_from( & session) ?) ;
161- Ok ( foreign_session. as_ref( ) . unwrap( ) )
162- } )
163- ) ;
164- let table_provider = rresult_return ! (
165- udtf_inner. call_with_args( TableFunctionArgs :: new( & args, session) )
166- ) ;
167- RResult :: ROk ( FFI_TableProvider :: new_with_ffi_codec (
168- table_provider,
169- false ,
170- runtime,
171- udtf. logical_codec . clone ( ) ,
172- ) )
173- }
174-
175119unsafe extern "C" fn release_fn_wrapper ( udtf : & mut FFI_TableFunction ) {
176120 unsafe {
177121 debug_assert ! ( !udtf. private_data. is_null( ) ) ;
@@ -232,9 +176,7 @@ impl FFI_TableFunction {
232176 let private_data = Box :: new ( TableFunctionPrivateData { udtf, runtime } ) ;
233177
234178 Self {
235- #[ expect( deprecated) ]
236179 call : call_fn_wrapper,
237- call_with_args : call_with_args_wrapper,
238180 logical_codec,
239181 clone : clone_fn_wrapper,
240182 release : release_fn_wrapper,
@@ -273,35 +215,13 @@ impl From<FFI_TableFunction> for Arc<dyn TableFunctionImpl> {
273215}
274216
275217impl TableFunctionImpl for ForeignTableFunction {
276- fn call_with_args ( & self , args : TableFunctionArgs ) -> Result < Arc < dyn TableProvider > > {
277- let session = FFI_SessionRef :: new (
278- args. session ( ) ,
279- self . 0 . runtime ( ) ,
280- self . 0 . logical_codec . clone ( ) ,
281- ) ;
282- let codec: Arc < dyn LogicalExtensionCodec > = ( & self . 0 . logical_codec ) . into ( ) ;
283- let expr_list = LogicalExprList {
284- expr : serialize_exprs ( args. exprs ( ) , codec. as_ref ( ) ) ?,
285- } ;
286- let filters_serialized = expr_list. encode_to_vec ( ) . into ( ) ;
287-
288- let table_provider =
289- unsafe { ( self . 0 . call_with_args ) ( & self . 0 , filters_serialized, session) } ;
290-
291- let table_provider = df_result ! ( table_provider) ?;
292- let table_provider: Arc < dyn TableProvider > = ( & table_provider) . into ( ) ;
293-
294- Ok ( table_provider)
295- }
296-
297- fn call ( & self , args : & [ datafusion_expr:: Expr ] ) -> Result < Arc < dyn TableProvider > > {
218+ fn call ( & self , args : & [ Expr ] ) -> Result < Arc < dyn TableProvider > > {
298219 let codec: Arc < dyn LogicalExtensionCodec > = ( & self . 0 . logical_codec ) . into ( ) ;
299220 let expr_list = LogicalExprList {
300221 expr : serialize_exprs ( args, codec. as_ref ( ) ) ?,
301222 } ;
302223 let filters_serialized = expr_list. encode_to_vec ( ) . into_iter ( ) . collect ( ) ;
303224
304- #[ expect( deprecated) ]
305225 let table_provider = unsafe { ( self . 0 . call ) ( & self . 0 , filters_serialized) } ;
306226
307227 let table_provider = df_result ! ( table_provider) ?;
@@ -322,22 +242,16 @@ mod tests {
322242 use datafusion:: logical_expr:: ptr_eq:: arc_ptr_eq;
323243 use datafusion:: prelude:: { SessionContext , lit} ;
324244 use datafusion:: scalar:: ScalarValue ;
325- use datafusion_catalog:: TableFunctionArgs ;
326245 use datafusion_execution:: TaskContextProvider ;
327- use datafusion_expr:: Expr ;
328246
329247 use super :: * ;
330248
331249 #[ derive( Debug ) ]
332250 struct TestUDTF { }
333251
334252 impl TableFunctionImpl for TestUDTF {
335- fn call_with_args (
336- & self ,
337- args : TableFunctionArgs ,
338- ) -> Result < Arc < dyn TableProvider > > {
253+ fn call ( & self , args : & [ Expr ] ) -> Result < Arc < dyn TableProvider > > {
339254 let args = args
340- . exprs ( )
341255 . iter ( )
342256 . map ( |arg| {
343257 if let Expr :: Literal ( scalar, _) = arg {
@@ -427,10 +341,7 @@ mod tests {
427341
428342 let foreign_udf: Arc < dyn TableFunctionImpl > = local_udtf. into ( ) ;
429343
430- let table = foreign_udf. call_with_args ( TableFunctionArgs :: new (
431- & [ lit ( 6_u64 ) , lit ( "one" ) , lit ( 2.0 ) , lit ( 3_u64 ) ] ,
432- & ctx. state ( ) ,
433- ) ) ?;
344+ let table = foreign_udf. call ( & [ lit ( 6_u64 ) , lit ( "one" ) , lit ( 2.0 ) , lit ( 3_u64 ) ] ) ?;
434345
435346 let _ = ctx. register_table ( "test-table" , table) ?;
436347
0 commit comments