-
Notifications
You must be signed in to change notification settings - Fork 28.4k
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-22945][SQL] add java UDF APIs in the functions object #20141
Conversation
cc @rxin @gatorsmile |
val udf = UserDefinedFunction(func, dataType, inputTypes).withName(name) | ||
if (nullable) udf else udf.asNonNullable() | ||
}""") | ||
|/** |
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.
just code style change, to use the multiline string format.
@@ -66,6 +66,7 @@ case class UserDefinedFunction protected[sql] ( | |||
* | |||
* @since 1.3.0 | |||
*/ | |||
@scala.annotation.varargs |
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.
to make it java friendly, or shall we create a new method for java?
* function (UDF). The data types are automatically inferred based on the function's | ||
* signature. To change a UDF to nondeterministic, call the API | ||
* `UserDefinedFunction.asNondeterministic()`. | ||
* Defines a Scala closure of 0 arguments as user-defined function (UDF). |
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.
to make the document consistent with UDFRegistration.register
Test build #85629 has finished for PR 20141 at commit
|
/** | ||
* Defines a Java UDF1 instance as user-defined function (UDF). | ||
* The caller must specify the output data type, and there is no automatic input type coercion. | ||
* By default the returned UDF is deterministic, to change it to nondeterministic, call the |
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: , to
-> . To
LGTM |
Test build #85658 has finished for PR 20141 at commit
|
## What changes were proposed in this pull request? Currently Scala users can use UDF like ``` val foo = udf((i: Int) => Math.random() + i).asNondeterministic df.select(foo('a)) ``` Python users can also do it with similar APIs. However Java users can't do it, we should add Java UDF APIs in the functions object. ## How was this patch tested? new tests Author: Wenchen Fan <[email protected]> Closes #20141 from cloud-fan/udf. (cherry picked from commit d5861ab) Signed-off-by: Wenchen Fan <[email protected]>
thanks, merging to master/2.3 |
What changes were proposed in this pull request?
Currently Scala users can use UDF like
Python users can also do it with similar APIs. However Java users can't do it, we should add Java UDF APIs in the functions object.
How was this patch tested?
new tests