- 
                Notifications
    
You must be signed in to change notification settings  - Fork 1.7k
 
Description
Is your feature request related to a problem or challenge?
Create physical scalar expression in functions modules from string
Currently more and more built-in scalar functions are moved to functions modules, e.g. #9435. It avoids using a long enum of all built-in scalar functions which is hard to maintain. But for Comet, we rely the ability to create a physical scalar expression from string (e.g., datepart).
Previously it is easy and just calls BuiltinScalarFunction::from_str to get BuiltinScalarFunction. But now I don't see such convenient function to do that.
FunctionRegistry provides udf which can return a reference to ScalarUDF. But it requires these UDFs must be registered. As we don't know what UDFs will be used, we need to register all built-in UDFs in the registry. The flaw is, it will create ScalarUDFs for all built-in UDFs even they are not actually used in the queries.
I think we still need an approach that can simply create a physical scalar expression in functions modules from string. So we can create corresponding ScalarUDF on demand.
Another approach might be to avoid creating ScalarUDFs when registering built-in scalar functions.
Avoid creating ScalarUDFs before they are actually used when registering in FunctionRegistry
Actually, I am also wondering if it is necessary to create and register all these ScalaUDFs in DataFusion's FunctionRegistry before these scalar UDFs are actually used.
For example, Spark's FunctionRegistry registers expression builders instead of creating actual expressions when registering built-in expressions. A built-in expression is created only if it is actually used by a query.
Describe the solution you'd like
No response
Describe alternatives you've considered
No response
Additional context
No response