sadboy commented on issue #8051:
URL: 
https://github.com/apache/arrow-datafusion/issues/8051#issuecomment-1863689720

   > the scalar function implementations that are passed around may be shared 
-- so using interior mutability would get confusing as each function invocation 
would be from the same instance of the function
   
   Hmm, not sure I'm following? I was thinking of the `ScalarFunctionExpr` 
physical node 
(https://docs.rs/datafusion-physical-expr/34.0.0/src/datafusion_physical_expr/scalar_function.rs.html#51),
 e.g. adding something like
   ```
   pub struct ScalarFunctionExpr {
   [...]
       args: Vec<Arc<dyn PhysicalExpr>>,
       prepared_args: OnceCell<Vec<Box<dyn PreparedArgs>>>,
   [...]
   }
   ```
   where `prepared_args` is populated by the return value of calling 
`ScalarFunction::prepare` on the set of physical `args`. The function 
implementation objects themselves do not need to mutate -- they only need to 
provide an optional implementation of `ScalarFunction::prepare` method if they 
wish to pre-process the arguments. `prepared_args` is purely an optimization 
construct, it should have no effect on the semantics of `ScalarFunctionExpr` -- 
the node should compute the exact same result whether or not `prepared_args` is 
populated. This way, any part of the system (e.g. `Serialize`, `Clone`, etc.) 
is always free to simply drop it without affecting correctness.


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