Interface SparkUdf
public interface SparkUdf
Contract for a Spark SQL user defined function (UDF) delivered as a plugin.
Applications discover implementations with
ServiceLoader, so every implementation must:
- be a public class with a public constructor without parameters;
- be listed in the file
META-INF/services/com.camelioflux.plugins.udf.coreudf.SparkUdfof its JAR, written by hand or generated by a tool such as Google AutoService; - return a name that no other plugin uses.
Typical use by an application:
for (SparkUdf udf : ServiceLoader.load(SparkUdf.class)) {
udf.register(spark);
}
- Since:
- 1.0.0
- Author:
- mannemlokesh
-
Method Summary
-
Method Details
-
getName
String getName()Returns the name under which the function is called in Spark SQL.The value must be the same on every call. Spark SQL function names are not case-sensitive, so names that differ only in case collide.
- Returns:
- the function name; never
nullor blank
-
register
void register(org.apache.spark.sql.SparkSession spark) Registers the function, undergetName(), with a Spark session.This runs on the driver. The function body runs on the executors, so everything it references must be serializable. Registering a name that already exists in the session replaces the earlier function.
- Parameters:
spark- the active session; nevernull
-