Package org.apache.spark.sql.expressions
Class UserDefinedFunction
Object
org.apache.spark.sql.expressions.UserDefinedFunction
- All Implemented Interfaces:
org.apache.spark.sql.internal.UserDefinedFunctionLike
public abstract class UserDefinedFunction
extends Object
implements org.apache.spark.sql.internal.UserDefinedFunctionLike
A user-defined function. To create one, use the
udf
functions in functions
.
As an example:
// Define a UDF that returns true or false based on some numeric score.
val predict = udf((score: Double) => score > 0.5)
// Projects a column that adds a prediction column based on the score column.
df.select( predict(df("score")) )
- Since:
- 1.3.0
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionReturns an expression that invokes the UDF, using the given arguments.Returns an expression that invokes the UDF, using the given arguments.abstract UserDefinedFunction
Updates UserDefinedFunction to nondeterministic.abstract UserDefinedFunction
Updates UserDefinedFunction to non-nullable.abstract boolean
Returns true iff the UDF is deterministic, i.e.abstract boolean
nullable()
Returns true when the UDF can return a nullable value.abstract UserDefinedFunction
Updates UserDefinedFunction with a given name.Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.apache.spark.sql.internal.UserDefinedFunctionLike
name
-
Constructor Details
-
UserDefinedFunction
public UserDefinedFunction()
-
-
Method Details
-
apply
Returns an expression that invokes the UDF, using the given arguments.- Parameters:
exprs
- (undocumented)- Returns:
- (undocumented)
- Since:
- 1.3.0
-
apply
Returns an expression that invokes the UDF, using the given arguments.- Parameters:
exprs
- (undocumented)- Returns:
- (undocumented)
- Since:
- 1.3.0
-
asNonNullable
Updates UserDefinedFunction to non-nullable.- Returns:
- (undocumented)
- Since:
- 2.3.0
-
asNondeterministic
Updates UserDefinedFunction to nondeterministic.- Returns:
- (undocumented)
- Since:
- 2.3.0
-
deterministic
public abstract boolean deterministic()Returns true iff the UDF is deterministic, i.e. the UDF produces the same output given the same input.- Returns:
- (undocumented)
- Since:
- 2.3.0
-
nullable
public abstract boolean nullable()Returns true when the UDF can return a nullable value.- Returns:
- (undocumented)
- Since:
- 2.3.0
-
withName
Updates UserDefinedFunction with a given name.- Parameters:
name
- (undocumented)- Returns:
- (undocumented)
- Since:
- 2.3.0
-