@@ -87,8 +87,6 @@ pub struct FFI_WindowUDF {
8787 arg_types : RVec < WrappedSchema > ,
8888 ) -> RResult < RVec < WrappedSchema > , RString > ,
8989
90- pub schema : unsafe extern "C" fn ( udwf : & Self ) -> WrappedSchema ,
91-
9290 pub sort_options : ROption < FFI_SortOptions > ,
9391
9492 /// Used to create a clone on the provider of the udf. This should
@@ -108,19 +106,13 @@ unsafe impl Sync for FFI_WindowUDF {}
108106
109107pub struct WindowUDFPrivateData {
110108 pub udf : Arc < WindowUDF > ,
111- pub schema : SchemaRef ,
112109}
113110
114111impl FFI_WindowUDF {
115112 unsafe fn inner ( & self ) -> & Arc < WindowUDF > {
116113 let private_data = self . private_data as * const WindowUDFPrivateData ;
117114 & ( * private_data) . udf
118115 }
119-
120- unsafe fn inner_schema ( & self ) -> SchemaRef {
121- let private_data = self . private_data as * const WindowUDFPrivateData ;
122- Arc :: clone ( & ( * private_data) . schema )
123- }
124116}
125117
126118unsafe extern "C" fn partition_evaluator_fn_wrapper (
@@ -167,12 +159,6 @@ unsafe extern "C" fn coerce_types_fn_wrapper(
167159 rresult ! ( vec_datatype_to_rvec_wrapped( & return_types) )
168160}
169161
170- unsafe extern "C" fn schema_fn_wrapper ( udwf : & FFI_WindowUDF ) -> WrappedSchema {
171- let schema = udwf. inner_schema ( ) ;
172-
173- schema. into ( )
174- }
175-
176162unsafe extern "C" fn release_fn_wrapper ( udwf : & mut FFI_WindowUDF ) {
177163 let private_data = Box :: from_raw ( udwf. private_data as * mut WindowUDFPrivateData ) ;
178164 drop ( private_data) ;
@@ -187,7 +173,6 @@ unsafe extern "C" fn clone_fn_wrapper(udwf: &FFI_WindowUDF) -> FFI_WindowUDF {
187173 // });
188174 let private_data = Box :: new ( WindowUDFPrivateData {
189175 udf : Arc :: clone ( udwf. inner ( ) ) ,
190- schema : udwf. inner_schema ( ) ,
191176 } ) ;
192177
193178 FFI_WindowUDF {
@@ -196,7 +181,6 @@ unsafe extern "C" fn clone_fn_wrapper(udwf: &FFI_WindowUDF) -> FFI_WindowUDF {
196181 volatility : udwf. volatility . clone ( ) ,
197182 partition_evaluator : partition_evaluator_fn_wrapper,
198183 sort_options : udwf. sort_options . clone ( ) ,
199- schema : schema_fn_wrapper,
200184 coerce_types : coerce_types_fn_wrapper,
201185 field : field_fn_wrapper,
202186 clone : clone_fn_wrapper,
@@ -211,22 +195,21 @@ impl Clone for FFI_WindowUDF {
211195 }
212196}
213197
214- impl FFI_WindowUDF {
215- pub fn new ( udf : Arc < WindowUDF > , schema : SchemaRef ) -> Self {
198+ impl From < Arc < WindowUDF > > for FFI_WindowUDF {
199+ fn from ( udf : Arc < WindowUDF > ) -> Self {
216200 let name = udf. name ( ) . into ( ) ;
217201 let aliases = udf. aliases ( ) . iter ( ) . map ( |a| a. to_owned ( ) . into ( ) ) . collect ( ) ;
218202 let volatility = udf. signature ( ) . volatility . into ( ) ;
219203 let sort_options = udf. sort_options ( ) . map ( |v| ( & v) . into ( ) ) . into ( ) ;
220204
221- let private_data = Box :: new ( WindowUDFPrivateData { udf, schema } ) ;
205+ let private_data = Box :: new ( WindowUDFPrivateData { udf } ) ;
222206
223207 Self {
224208 name,
225209 aliases,
226210 volatility,
227211 partition_evaluator : partition_evaluator_fn_wrapper,
228212 sort_options,
229- schema : schema_fn_wrapper,
230213 coerce_types : coerce_types_fn_wrapper,
231214 field : field_fn_wrapper,
232215 clone : clone_fn_wrapper,
@@ -307,8 +290,7 @@ impl WindowUDFImpl for ForeignWindowUDF {
307290 args : datafusion:: logical_expr:: function:: PartitionEvaluatorArgs ,
308291 ) -> Result < Box < dyn PartitionEvaluator > > {
309292 let evaluator = unsafe {
310- let schema = ( self . udf . schema ) ( & self . udf ) ;
311- let args = FFI_PartitionEvaluatorArgs :: new ( args, schema. into ( ) ) ?;
293+ let args = FFI_PartitionEvaluatorArgs :: try_from ( args) ?;
312294 ( self . udf . partition_evaluator ) ( & self . udf , args)
313295 } ;
314296
0 commit comments