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

   Thanks @2010YOUY01 !
   
   > We have to move the function registry into SessionConfig first (or is 
there any better way?)
   
   What if we changed how `Expr::ScalarFunction` looks (and remove 
`Expr::ScalarUDF`:
   
   ```rust
   enum Expr {
   ...
       /// Represents the call of a built-in, or UDF scalar function with a set 
of arguments.
       ScalarFunction(ScalarFunction),
   ...
   }
   ```
   
   
   Instead of 
   
   
   ```rust
   #[derive(Clone, PartialEq, Eq, Hash, Debug)]
   pub struct ScalarFunction {
       /// The function
       pub fun: built_in_function::BuiltinScalarFunction,
       /// List of expressions to feed to the functions as arguments
       pub args: Vec<Expr>,
   }
   ```
   
   Make it look like
   
   ```rust
   pub enum ScalarFunctionDefinition {
     /// Resolved to a built in scalar function
     /// (will be removed long term)
     BuiltIn(built_in_function::BuiltinScalarFunction),
     /// Resolved to a user defined function
     UDF(ScalarUDF),
     /// A scalar function that will be called by name
     Name(Arc<str>),
   }
   
   #[derive(Clone, PartialEq, Eq, Hash, Debug)]
   pub struct ScalarFunction {
       /// The function
       pub fun: ScalarFunctionDefinition,
       /// List of expressions to feed to the functions as arguments
       pub args: Vec<Expr>,
   }
   ```
   
   And that way an expr function like `abs` could look like
   
   ```rust
   fn abs(arg: Expr) -> Expr {
     Expr::ScaarFunction {
       fun: ScalarFunctionDefintion::Name("abs".into()),
       args: vec![arg],
     }
   }
   ```
   
   I am not sure how large of a change this would be -- we would have to try it 
and see what it looked like. 


-- 
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