-
Notifications
You must be signed in to change notification settings - Fork 29k
[SPARK-54856][SQL] Refactor scalar function lookup and resolution #53627
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
base: master
Are you sure you want to change the base?
Conversation
|
cc @pan3793 |
| val funcName = qualifiedIdent.funcName | ||
| if (registry.functionExists(qualifiedIdent)) { | ||
| // This function has been already loaded into the function registry. | ||
| registry.lookupFunction(qualifiedIdent, arguments) |
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 previously assumed the second round would go here, seems not?
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.
v2 function does not support table function yet, so scalar and table functions has different code paths:
- scalar function looks up the cache at https://github.com/apache/spark/pull/53627/files#diff-9dd0899e5406230aeff96654432da54f35255f6dc60eecb87264a5c508a8c826R2186
- table function looks up the cache at https://github.com/apache/spark/pull/53627/files#diff-9dd0899e5406230aeff96654432da54f35255f6dc60eecb87264a5c508a8c826R2236
| * Create a metadata-only V1Function (for DESCRIBE FUNCTION). | ||
| * If invoke() is called, it will throw an error. | ||
| */ | ||
| def apply(info: ExpressionInfo): V1Function = { |
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.
after this change, calling V1Function(info) would go from the constructor to here, maybe it should use a different name to avoid abuse (especially by external plugins), or just remove it and require the caller to use metadataOnlyBuilder explicitly
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.
good point!
What changes were proposed in this pull request?
This PR adds
loadPersistentScalarFunctionmethod toSessionCatalog, to unify the scalar function lookup and resolution between v1 and v2 catalogs. The key difference between v1 and v2 catalogs about function is:lookupPersistentFunctionandresolvePersistentFunction.loadFunction. This API returnsUnboundFunction, for invocation, it needs to enter the second phase and callUnboundFunction.bind.The newly added
loadPersistentScalarFunctionmethod follows the v2 catalog style and handles function invocation (load resources and create function builder) in a second phase.Why are the changes needed?
Code cleanup, also also avoid redundant function lookup from catalog introduced by #53531
Does this PR introduce any user-facing change?
No
How was this patch tested?
existing tests
Was this patch authored or co-authored using generative AI tooling?
cursor 2.2.44