-
Notifications
You must be signed in to change notification settings - Fork 28.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
[SPARK-25560][SQL] Allow FunctionInjection in SparkExtensions #22576
Conversation
@hvanhovell Made a full PR for the change we discussed. Also updated the signature to match the new defined types for the registry and Identifier. |
Test build #96728 has finished for PR 22576 at commit
|
Test build #96757 has finished for PR 22576 at commit
|
Looks like the session with extensions from the test suite is leaking to
other suites ... Investigating
…On Fri, Sep 28, 2018 at 11:25 AM UCB AMPLab ***@***.***> wrote:
Test FAILed.
Refer to this link for build results (access rights to CI server needed):
https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/96757/
Test FAILed.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#22576 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AAZNYTu9vCM3h2Z-SgFqxpB3PLKg5o7kks5ufk1igaJpZM4W9uz9>
.
|
Ah I was registering functions with the built-in registry which is not reset. I've changed it to register only with a clone of the built-in registry. This would allow multiple extensions, or some sessions to use extensions and others not to |
Test build #96769 has finished for PR 22576 at commit
|
private[this] val injectedFunctions = | ||
mutable.Buffer.empty[FunctionDescription] | ||
|
||
private[sql] def registerFunctions(functionRegistry: FunctionRegistry) = { |
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.
Can you fix the indentation for the next 14 lines?
@@ -95,7 +95,8 @@ abstract class BaseSessionStateBuilder( | |||
* This either gets cloned from a pre-existing version or cloned from the built-in registry. | |||
*/ | |||
protected lazy val functionRegistry: FunctionRegistry = { | |||
parentState.map(_.functionRegistry).getOrElse(FunctionRegistry.builtin).clone() | |||
parentState.map(_.functionRegistry.clone()) | |||
.getOrElse{extensions.registerFunctions(FunctionRegistry.builtin.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.
NIT: Use parenthesis instead of curly braces?
@@ -168,4 +173,22 @@ class SparkSessionExtensions { | |||
def injectParser(builder: ParserBuilder): Unit = { | |||
parserBuilders += builder | |||
} | |||
|
|||
private[this] val injectedFunctions = |
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.
NIT: no new line?
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.
Couple of style remarks, but looks good in general.
This allows an implementer of Spark Session Extensions to utilize a method "injectFunction" which will add a new function to the default Spark Session Catalog.
Cleaned up |
Test build #97462 has finished for PR 22576 at commit
|
retest this please |
Test build #97576 has finished for PR 22576 at commit
|
private[this] val injectedFunctions = mutable.Buffer.empty[FunctionDescription] | ||
|
||
private[sql] def registerFunctions(functionRegistry: FunctionRegistry) = { | ||
for ((name, expressionInfo, function) <- injectedFunctions) { |
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.
Can you move the stuff that changes the FunctionRegistry
into the BaseSessionStateBuilder
and just make this return the Seq[FunctionDescription]
? The return type of this function a FunctionRegistry
sort of implies that you are getting back a new registry instead of a mutated one. If we are mutating then I prefer to do that in the BaseSessionBuilder so it is obvious that this is safe to do because we mutating a clone. It also makes this code more inline with the rest of the extension class (not mutating). Sorry for the late change of heart.
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.
Ha we just changed a function in the opposite direction on my other commit. The project should probably pick one dorm and put it in the style guide. I'll make the chznge
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.
👍
@RussellSpitzer I am merging this, can you address my comment in a follow up? Thanks! |
This allows an implementer of Spark Session Extensions to utilize a method "injectFunction" which will add a new function to the default Spark Session Catalogue. ## What changes were proposed in this pull request? Adds a new function to SparkSessionExtensions def injectFunction(functionDescription: FunctionDescription) Where function description is a new type type FunctionDescription = (FunctionIdentifier, FunctionBuilder) The functions are loaded in BaseSessionBuilder when the function registry does not have a parent function registry to get loaded from. ## How was this patch tested? New unit tests are added for the extension in SparkSessionExtensionSuite Closes apache#22576 from RussellSpitzer/SPARK-25560. Authored-by: Russell Spitzer <Russell.Spitzer@gmail.com> Signed-off-by: Herman van Hovell <hvanhovell@databricks.com>
This allows an implementer of Spark Session Extensions to utilize a
method "injectFunction" which will add a new function to the default
Spark Session Catalogue.
What changes were proposed in this pull request?
Adds a new function to SparkSessionExtensions
Where function description is a new type
type FunctionDescription = (FunctionIdentifier, FunctionBuilder)
The functions are loaded in BaseSessionBuilder when the function registry does not have a parent
function registry to get loaded from.
How was this patch tested?
New unit tests are added for the extension in SparkSessionExtensionSuite