Trikooo opened a new issue, #20290:
URL: https://github.com/apache/datafusion/issues/20290
### Is your feature request related to a problem or challenge?
Related to #20012
Currently, the return field of `ScalarFunction`s is being computed three
times during the query's lifecycle, during which the query's expression might
change.
for example when a udf needs to implicitly cast a literal, it wraps that
literal in a cast and recomputes the return field again after initial
computation without the cast, leading to inconsistent results.
### Describe the solution you'd like
Calculate the `return_type` during creation.
```rust
#[derive(Clone, PartialEq, Eq, PartialOrd, Hash, Debug)]
pub struct ScalarFunction {
/// The function
pub func: Arc<crate::ScalarUDF>,
/// List of expressions to feed to the functions as arguments
pub args: Vec<Expr>,
/// Return field of the function
return_field: FieldRef,
}
```
Not sure if a new constructor `ScalarFunction::new_udf_with_return_field`
should be created or change the original `ScalarFunction::new_udf`
### Describe alternatives you've considered
_No response_
### Additional context
#13825 proposed a similar approach.
--
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]