UserDefinedFunction (Spark 4.2.0 JavaDoc)
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
Constructors
-
Method Summary
Returns an expression that invokes the UDF, using the given arguments.
apply(scala.collection.immutable.Seq<Column> exprs) Returns an expression that invokes the UDF, using the given arguments.
Updates UserDefinedFunction to nondeterministic.
Updates UserDefinedFunction to non-nullable.
abstract booleanReturns true iff the UDF is deterministic, i.e.
abstract booleannullable()Returns true when the UDF can return a nullable value.
Updates UserDefinedFunction with a given name.
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
public Column apply
(scala.collection.immutable.Seq<Column> exprs) 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
-