Skip to content

Conversation

@cloud-fan
Copy link
Contributor

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

@cloud-fan
Copy link
Contributor Author

cc @rxin @gatorsmile

val udf = UserDefinedFunction(func, dataType, inputTypes).withName(name)
if (nullable) udf else udf.asNonNullable()
}""")
|/**
Copy link
Contributor Author

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.

*
* @since 1.3.0
*/
@scala.annotation.varargs
Copy link
Contributor Author

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).
Copy link
Contributor Author

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

@SparkQA
Copy link

SparkQA commented Jan 3, 2018

Test build #85629 has finished for PR 20141 at commit 160cb61.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

/**
* 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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: , to -> . To

@gatorsmile
Copy link
Member

LGTM

@SparkQA
Copy link

SparkQA commented Jan 4, 2018

Test build #85658 has finished for PR 20141 at commit 711c027.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

asfgit pushed a commit that referenced this pull request Jan 4, 2018
## 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]>
@cloud-fan
Copy link
Contributor Author

thanks, merging to master/2.3

@asfgit asfgit closed this in d5861ab Jan 4, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants