-
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
refactor: simplify the make_udf_function
macro
#13712
Conversation
($UDF:ty, $GNAME:ident, $NAME:ident) => { | ||
#[doc = "Return a [`ScalarUDF`](datafusion_expr::ScalarUDF) implementation "] | ||
#[doc = stringify!($UDF)] | ||
($UDF:ty, $NAME:ident) => { |
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.
Here is the main change.
pub fn $NAME() -> std::sync::Arc<datafusion_expr::ScalarUDF> { | ||
// Singleton instance of the function | ||
static $GNAME: std::sync::LazyLock< | ||
static INSTANCE: std::sync::LazyLock< |
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.
here we go where lazy lock shines
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 thanks @jonahgao
Thanks @comphead @jayzhan211 for the review |
Which issue does this PR close?
Follow-up of #13674 (comment)
Rationale for this change
By limiting the
ScalarUDF
singleton to the function scope, we can remove$GNAME
from themake_udf_function
macro. Macro callers no longer need to provide a unique singleton name.Before:
After:
What changes are included in this PR?
Are these changes tested?
Yes.
Are there any user-facing changes?
No. Those macros are not exported and are not public APIs.