2010YOUY01 opened a new issue, #18643: URL: https://github.com/apache/datafusion/issues/18643
### Is your feature request related to a problem or challenge? When implementing optimizer rules, it's common to check if a expression is certain function. Now it's commonly done through function name match check. A potential risk is: datafusion dependents might override the function implementation in the function registry, in such cases those optimizer rules should not be enabled, it's better to figure out a way to accurately check the function type. I believe now they're done through name match because all function implementations live in a different crate than optimizer, and we don't want to add a crate dependency between them, so we can't do the trait object downcasting for type check. One way I can think of is add a `source()` API in UDFs, so we can differentiate if this is builtin or added by the 3rd party, and in the optimizer we can check it safer like `fun.source() == BuiltIn && fun.name() == "min"` Current optimizer examples for checking function type by name matching: https://github.com/apache/datafusion/blob/0d52a1eebe403790a480ba404c2fe65b1aa1e897/datafusion/optimizer/src/single_distinct_to_groupby.rs#L90-L92 https://github.com/apache/datafusion/blob/0d52a1eebe403790a480ba404c2fe65b1aa1e897/datafusion/optimizer/src/analyzer/resolve_grouping_function.rs#L151-L153 https://github.com/apache/datafusion/blob/0d52a1eebe403790a480ba404c2fe65b1aa1e897/datafusion/optimizer/src/decorrelate.rs#L496 ### Describe the solution you'd like _No response_ ### Describe alternatives you've considered _No response_ ### Additional context _No response_ -- 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]
