2010YOUY01 opened a new pull request, #7752: URL: https://github.com/apache/arrow-datafusion/pull/7752
## Which issue does this PR close? <!-- We generally require a GitHub issue to be filed for all bug fixes and enhancements and this helps us generate change logs for our releases. You can link an issue to this PR using the GitHub syntax. For example `Closes #123` indicates that this PR will close issue #123. --> POC for https://github.com/apache/arrow-datafusion/issues/7110 ## Rationale for this change 1. #7110 2. Also possibly clean up the current `BuiltinScalarFunction` implementation: now built-in functions are defined as a huge ENUM, and there are several large functions to determine signature/etc. for each function ENUM variant. Adding a function requires changing multiple places/files, this PR proposed a simpler interface to define a new function. This POC PR defined a package of test functions in a separate crate, and demonstrated how to register them into the context in `datafusion-examples/examples/external_function_package.rs` ## What changes are included in this PR? ### 1. `ScalarFunctionDef` trait as an alternative way to define scalar functions `Struct ScalarUDF` is currently the internal representation of UDF's logical plan, it should be expressive enough to implement all built-in functions. (with some minor changes like supporting alias) `ScalarFunctionDef` trait can be used to define scalar functions, and the trait object can be converted into `ScalarUDF`, and reuse UDF infrastructures to register and use the functions. ### 2. Managing extension points Another issue is how to manage those pluggable crates, possibly with a `extension/` folder under datafusion root? Recently I saw discussions about pulling parquet reader outside the core, those optional extension points can all be placed inside `extension/` folder ``` . ├── extension │ ├── data-source │ │ └── parquet-reader │ └── scalar-function │ ├── hash-functions │ ├── string-functions │ └── ... ``` For example `arrow-datafusion/extension/scalar-function/hash-functions` is a separate crate defined all hash-related functions. If this approach is possible I can try to pull some functions from datafusion core into a separate crate after <!-- There is no need to duplicate the description in the issue here but it is sometimes worth providing a summary of the individual changes in this PR. --> ## Are these changes tested? <!-- We typically require tests for all PRs in order to: 1. Prevent the code from being accidentally broken by subsequent changes 4. Serve as another way to document the expected behavior of the code If tests are not included in your PR, please explain why (for example, are they covered by existing tests)? --> ## Are there any user-facing changes? <!-- If there are user-facing changes then we may require documentation to be updated before approving the PR. --> <!-- If there are any breaking changes to public APIs, please add the `api change` label. --> -- 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]
