@@ -266,24 +266,30 @@ impl<T: SourceFactoryBase> SourceFactory for T {
266266// Function
267267////////////////////////////////////////////////////////
268268
269+ pub struct SimpleFunctionAnalysisOutput < T : Send + Sync > {
270+ pub resolved_args : T ,
271+ pub output_schema : EnrichedValueType ,
272+ pub behavior_version : Option < u32 > ,
273+ }
274+
269275#[ async_trait]
270276pub trait SimpleFunctionFactoryBase : SimpleFunctionFactory + Send + Sync + ' static {
271277 type Spec : DeserializeOwned + Send + Sync ;
272278 type ResolvedArgs : Send + Sync ;
273279
274280 fn name ( & self ) -> & str ;
275281
276- async fn resolve_schema < ' a > (
282+ async fn analyze < ' a > (
277283 & ' a self ,
278284 spec : & ' a Self :: Spec ,
279285 args_resolver : & mut OpArgsResolver < ' a > ,
280286 context : & FlowInstanceContext ,
281- ) -> Result < ( Self :: ResolvedArgs , EnrichedValueType ) > ;
287+ ) -> Result < SimpleFunctionAnalysisOutput < Self :: ResolvedArgs > > ;
282288
283289 async fn build_executor (
284290 self : Arc < Self > ,
285291 spec : Self :: Spec ,
286- resolved_input_schema : Self :: ResolvedArgs ,
292+ resolved_args : Self :: ResolvedArgs ,
287293 context : Arc < FlowInstanceContext > ,
288294 ) -> Result < impl SimpleFunctionExecutor > ;
289295
@@ -317,10 +323,6 @@ impl<E: SimpleFunctionExecutor> SimpleFunctionExecutor for FunctionExecutorWrapp
317323 fn enable_cache ( & self ) -> bool {
318324 self . executor . enable_cache ( )
319325 }
320-
321- fn behavior_version ( & self ) -> Option < u32 > {
322- self . executor . behavior_version ( )
323- }
324326}
325327
326328#[ async_trait]
@@ -330,10 +332,7 @@ impl<T: SimpleFunctionFactoryBase> SimpleFunctionFactory for T {
330332 spec : serde_json:: Value ,
331333 input_schema : Vec < OpArgSchema > ,
332334 context : Arc < FlowInstanceContext > ,
333- ) -> Result < (
334- EnrichedValueType ,
335- BoxFuture < ' static , Result < Box < dyn SimpleFunctionExecutor > > > ,
336- ) > {
335+ ) -> Result < SimpleFunctionBuildOutput > {
337336 let spec: T :: Spec = utils:: deser:: from_json_value ( spec)
338337 . with_context ( || format ! ( "Failed in parsing spec for function `{}`" , self . name( ) ) ) ?;
339338 let mut nonnull_args_idx = vec ! [ ] ;
@@ -343,9 +342,11 @@ impl<T: SimpleFunctionFactoryBase> SimpleFunctionFactory for T {
343342 & mut nonnull_args_idx,
344343 & mut may_nullify_output,
345344 ) ?;
346- let ( resolved_input_schema, mut output_schema) = self
347- . resolve_schema ( & spec, & mut args_resolver, & context)
348- . await ?;
345+ let SimpleFunctionAnalysisOutput {
346+ resolved_args,
347+ mut output_schema,
348+ behavior_version,
349+ } = self . analyze ( & spec, & mut args_resolver, & context) . await ?;
349350 args_resolver. done ( ) ?;
350351
351352 // If any required argument is nullable, the output schema should be nullable.
@@ -355,13 +356,15 @@ impl<T: SimpleFunctionFactoryBase> SimpleFunctionFactory for T {
355356
356357 let executor = async move {
357358 Ok ( Box :: new ( FunctionExecutorWrapper {
358- executor : self
359- . build_executor ( spec, resolved_input_schema, context)
360- . await ?,
359+ executor : self . build_executor ( spec, resolved_args, context) . await ?,
361360 nonnull_args_idx,
362361 } ) as Box < dyn SimpleFunctionExecutor > )
363362 } ;
364- Ok ( ( output_schema, Box :: pin ( executor) ) )
363+ Ok ( SimpleFunctionBuildOutput {
364+ output_type : output_schema,
365+ behavior_version,
366+ executor : Box :: pin ( executor) ,
367+ } )
365368 }
366369}
367370
@@ -373,10 +376,6 @@ pub trait BatchedFunctionExecutor: Send + Sync + Sized + 'static {
373376 false
374377 }
375378
376- fn behavior_version ( & self ) -> Option < u32 > {
377- None
378- }
379-
380379 fn timeout ( & self ) -> Option < std:: time:: Duration > {
381380 None
382381 }
@@ -406,19 +405,16 @@ impl<E: BatchedFunctionExecutor> batching::Runner for BatchedFunctionExecutorRun
406405struct BatchedFunctionExecutorWrapper < E : BatchedFunctionExecutor > {
407406 batcher : batching:: Batcher < BatchedFunctionExecutorRunner < E > > ,
408407 enable_cache : bool ,
409- behavior_version : Option < u32 > ,
410408 timeout : Option < std:: time:: Duration > ,
411409}
412410
413411impl < E : BatchedFunctionExecutor > BatchedFunctionExecutorWrapper < E > {
414412 fn new ( executor : E ) -> Self {
415413 let batching_options = executor. batching_options ( ) ;
416414 let enable_cache = executor. enable_cache ( ) ;
417- let behavior_version = executor. behavior_version ( ) ;
418415 let timeout = executor. timeout ( ) ;
419416 Self {
420417 enable_cache,
421- behavior_version,
422418 timeout,
423419 batcher : batching:: Batcher :: new (
424420 BatchedFunctionExecutorRunner ( executor) ,
@@ -437,9 +433,6 @@ impl<E: BatchedFunctionExecutor> SimpleFunctionExecutor for BatchedFunctionExecu
437433 fn enable_cache ( & self ) -> bool {
438434 self . enable_cache
439435 }
440- fn behavior_version ( & self ) -> Option < u32 > {
441- self . behavior_version
442- }
443436 fn timeout ( & self ) -> Option < std:: time:: Duration > {
444437 self . timeout
445438 }
0 commit comments