Skip to content

Write a plugin

  1. Create a repository under camelioflux/plugins/user-defined-function-plugins, named <thing>-udf.

  2. Depend on the contract and on Spark (Spark is provided, because the cluster has it):

    <dependency>
    <groupId>com.camelioflux.plugins.udf</groupId>
    <artifactId>core-udf</artifactId>
    <version>1.0.0</version>
    </dependency>
  3. Implement SparkUdf:

    @AutoService(SparkUdf.class)
    public final class MaxUdf implements SparkUdf {
    public String getName() { return "MAXOF"; }
    public void register(SparkSession spark) {
    spark.udf().register("MAXOF", (UDF1<Seq<Number>, Double>) values -> /* ... */, DataTypes.DoubleType);
    }
    }
  4. Test it: one plain unit test for the logic and one with a local Spark session.

  5. Use the shared pipeline by adding a .gitlab-ci.yml that includes pipelines/maven-library.yml from ci-templates.

  6. Document it by adding a page under src/content/docs/plugins/ in this site and an entry in src/data/plugins.json.

Choose a name that no other plugin uses. Spark SQL ignores case.