Skip to content

startreedata/pinot-udf-examples

Repository files navigation

Apache Pinot UDF Examples

A collection of User Defined Functions (UDFs) for Apache Pinot version 1.3.0.

Overview

This project demonstrates how to create custom scalar functions for Apache Pinot. The example includes a few simple functions that can be used in Pinot queries.

Project Structure

src/main/java/org/apache/pinot/common/function/scalar/
├── MyFunction.java    # Example UDF implementation

Prerequisites

  • Java 21 or higher
  • Apache Pinot 1.3.0
  • Maven 3.6 or higher

Building

To build the project:

mvn clean package

This will create a shaded JAR file in the target directory: pinot-udf-examples-1.0-SNAPSHOT.jar

Installation

  1. Copy the built JAR to your Pinot installation's plugin library directory:

    mkdir $PINOT_HOME/plugins/pinot-udfs
    cp target/pinot-udf-examples-1.0-SNAPSHOT.jar $PINOT_HOME/plugins/pinot-udfs/
  2. Restart all your Pinot components:

Creating New UDFs

To add a new UDF:

  1. Create a new class in the org.apache.pinot.common.function.scalar package
  2. Add the @ScalarFunction annotation to your method
  3. Specify the function name(s) in the annotation, or default to the function name
  4. Build the project and copy the new JAR to Pinot's library directory

Example:

@ScalarFunction(names = {"myFunction"})
public static double myFunction(double input) {
    // Your implementation here
    return result;
}

Notes

  • The project uses provided scope for Pinot dependencies to avoid packaging them in the final JAR
  • The UDFs under pacakge org.apache.pinot.common.function.scalar are automatically registered with Pinot through the @ScalarFunction annotation
  • Make sure to restart Pinot components after adding new UDFs

About

An example of building UDFs for Apache Pinot

Topics

Resources

License

Stars

Watchers

Forks

Languages