-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Closed
Labels
enhancementNew feature or requestNew feature or request
Description
Is your feature request related to a problem or challenge?
The current way a user implements a ScalarUDF is awkward:
They must wade through several Arc<dyn<...> typedefs to figure out how to provide the type signature and implementation
pub fn new(
name: &str,
signature: &Signature,
return_type: &Arc<dyn Fn(&[DataType]) -> Result<Arc<DataType>, DataFusionError> + Send + Sync>,
fun: &Arc<dyn Fn(&[ColumnarValue]) -> Result<ColumnarValue, DataFusionError> + Send + Sync>
) -> ScalarUDFThe create_udf is somewhat easier to use, but it still requires Arc's of anonymous functions
Describe the solution you'd like
I am not sure why this API is implemented like it is. If I were a user I would expect to be able to use a trait object
like
struct MyUDF {
..
}
impl FunctionDefintion for MyUDF {
fn name(&self) -> &str,
fn return_type(&self) -> &DataType,
...
}Describe alternatives you've considered
No response
Additional context
I want to make ScalarUDFs easy to define for two reasons:
- they are a key API for DataFusion
- As we work on making all scalar functions
ScalarUDF[EPIC] Unify Function Interface (removeBuiltInScalarFunction) #8045 the easer it is to make UDFs the easier it is to complete that task
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request