case classUserDefinedFunction(f: AnyRef, dataType: DataType, inputTypes: Option[Seq[DataType]]) extends Product with Serializable
A user-defined function. To create one, use the udf functions in functions.
Note that the user-defined functions must be deterministic. Due to optimization,
duplicate invocations may be eliminated or the function may even be invoked more times than
it is present in the query.
As an example:
// Defined a UDF that returns true or false based on some numeric score.val predict = udf((score: Double) =>if (score > 0.5) trueelsefalse)
// Projects a column that adds a prediction column based on the score column.
df.select( predict(df("score")) )
A user-defined function. To create one, use the
udf
functions in functions. Note that the user-defined functions must be deterministic. Due to optimization, duplicate invocations may be eliminated or the function may even be invoked more times than it is present in the query. As an example:1.3.0