jayzhan211 commented on issue #10423:
URL: https://github.com/apache/datafusion/issues/10423#issuecomment-2101702285

   I found that to have `coerce_types` for both scalarUDF and aggregateUDF, I 
would need to introduce a more general trait for both function
   
   ```rust
   impl UDFImpl for T {
       fn name(&self) -> &str {
          &self.name
       }
   
       fn coerce_types(&self, data_types: &[DataType]) -> Result<Vec<DataType>> 
{
           not_impl_err!("Function {} does not implement coerce_types", 
self.name)
       }
   }
   
   impl ScalarUDFImpl: UDFImpl for T
   impl AggregateUDFImpl: UDFImpl for T
   ```
   Then we can have
   ```
   fn coerce_arguments_for_signature(
       expressions: Vec<Expr>,
       schema: &DFSchema,
       signature: &Signature,
       func: Arc<dyn UDFImpl>,
   ) -> Result<Vec<Expr>> {}
   ```
   
   Another alternative is having a duplicate function for scalar and aggregate 
for a related function
   
   ```
   fn coerce_arguments_for_signature(
       expressions: Vec<Expr>,
       schema: &DFSchema,
       signature: &Signature,
       func: &ScalarUDF,
   ) -> Result<Vec<Expr>> {}
   
   fn coerce_arguments_for_signature(
       expressions: Vec<Expr>,
       schema: &DFSchema,
       signature: &Signature,
       func: &AggregateUDF,
   ) -> Result<Vec<Expr>> {}
   ```
   
   I think the first option is potentially beneficial in the long run(?)
   @alamb what do you think?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscr...@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscr...@datafusion.apache.org
For additional commands, e-mail: github-h...@datafusion.apache.org

Reply via email to