-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add FunctionRegistry::register_udaf
and FunctionRegistry::register_udwf
#9075
Conversation
c0d88f7
to
7eeb52e
Compare
state | ||
.scalar_functions | ||
.insert(f.name().to_string(), Arc::new(f)); | ||
state.register_udf(Arc::new(f)).ok(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
moved into SessionState -- it is important that the alias resolution is done there so when new functions are registered via SessionState
their aliases are as well. Otherwise aliases are only added when the function is defined via SessionContext
/// | ||
/// Returns an error (the default) if the function can not be registered, | ||
/// for example if the registry is read only. | ||
fn register_udaf( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the key (backwards compatible) API addition in this PR.
It sets us up for being able to pull out BuiltInAggregate and BuiltInWindowFunction
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm wondering why this is a backwards compatible API? Does FunctionRegistry
provide this API before?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it is backwards compatible because it provides a default implementation (to return a Not Yet Implemented error)
Thus, any existing implementations of FunctionRegistry
will continue to compile and work as it did before, without any required code changes
7eeb52e
to
4257c16
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm as for me @alamb
Maybe we can do a one liner in register_udf
let aliases = udf.aliases(); | ||
for alias in aliases { | ||
self.scalar_functions.insert(alias.to_string(), udf.clone()); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
} |
Co-authored-by: comphead <[email protected]> Co-authored-by: Liang-Chi Hsieh <[email protected]>
Which issue does this PR close?
Closes #9074
Part of #8045 (making functions modular in DataFusion)
Rationale for this change
See #9074 (basically set us up for pulling aggregates and window functions out of the core)
What changes are included in this PR?
FunctionRegistry::register_udaf
andFunctionRegistry::register_udwf
SessionState
SessionContext
to use that API rather than modifying session state directlyAre these changes tested?
Covered by existing tests
Are there any user-facing changes?