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.SparkUdf of 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

    Modifier and Type
    Method
    Description
    Returns the name under which the function is called in Spark SQL.
    void
    register(org.apache.spark.sql.SparkSession spark)
    Registers the function, under getName(), with a Spark session.
  • 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 null or blank
    • register

      void register(org.apache.spark.sql.SparkSession spark)
      Registers the function, under getName(), 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; never null