UDFRegistration¶
UDFRegistration
is a facade to a session-scoped FunctionRegistry to register user-defined functions (UDFs) and user-defined aggregate functions (UDAFs).
Creating Instance¶
UDFRegistration
takes the following to be created:
UDFRegistration
is created when:
BaseSessionStateBuilder
is requested for the UDFRegistration
Accessing UDFRegistration¶
UDFRegistration
is available using SparkSession.udf.
import org.apache.spark.sql.SparkSession
assert(spark.isInstanceOf[SparkSession])
import org.apache.spark.sql.UDFRegistration
assert(spark.udf.isInstanceOf[UDFRegistration])
SessionState¶
UDFRegistration
is used to create a SessionState.
Registering UserDefinedFunction¶
register(
name: String,
udf: UserDefinedFunction): UserDefinedFunction
register
associates the given name with the given UserDefinedFunction.
register
requests the FunctionRegistry to createOrReplaceTempFunction under the given name and with scala_udf
source name and a function builder based on the type of the UserDefinedFunction
:
- For UserDefinedAggregators, the function builder requests the
UserDefinedAggregator
for a ScalaAggregator - For all other types, the function builder requests the
UserDefinedFunction
for a Column and takes the Expression