alamb commented on issue #8157:
URL: 
https://github.com/apache/arrow-datafusion/issues/8157#issuecomment-1843789027

   > So I am not sure I understood correctly. I could see that call_fn resolves 
at invocation site rather than at planning site, and changing the behavior 
would probably mean changing this code. What is the right type of Expr this 
code should return?
   
   I think the idea would be to make it be something like this
   ```rust
   /// Calls a named function
   /// ```
   /// use datafusion_expr::{col, lit, call_fn};
   ///
   /// // create the expression sin(x) < 0.2
   /// let expr = call_fn("sin", vec![col("x")]).unwrap().lt(lit(0.2));
   /// ```
   pub fn call_fn(name: impl AsRef<str>, args: Vec<Expr>) -> Result<Expr> {
        
Ok(Expr::ScalarFunction(ScalarFunctionDefinition::Name(Arc::new(name.as_ref()))
   }```
   
   And then add code to replace instances of `ScalarFunctionDefinition::Name` 
with either `ScalarFunctionDefinition::BuiltIn` or `ScalarFunction::Udf` to the 
optimizer. 
   
   Perhaps you can use the same logic here: 
https://github.com/apache/arrow-datafusion/blob/d9d8ddd5f770817f325190c4c0cc02436e7777e6/datafusion/sql/src/expr/function.rs#L66-L76
   
   BTW the point of doing this is so we can remove `BuiltInScalarFunction` 
eventually  incrementally and treat all functions the same


-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to