org.apache.spark.sql
Class UserDefinedFunction
Object
org.apache.spark.sql.UserDefinedFunction
- All Implemented Interfaces:
- java.io.Serializable, scala.Equals, scala.Product
public class UserDefinedFunction
- extends Object
- implements scala.Product, scala.Serializable
A user-defined function. To create one, use the udf
functions in functions
.
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) true else false)
// Projects a column that adds a prediction column based on the score column.
df.select( predict(df("score")) )
- Since:
- 1.3.0
- See Also:
- Serialized Form
Methods inherited from class Object |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface scala.Product |
productArity, productElement, productIterator, productPrefix |
Methods inherited from interface scala.Equals |
canEqual, equals |
f
public Object f()
dataType
public DataType dataType()
apply
public Column apply(scala.collection.Seq<Column> exprs)