A collection of User Defined Functions (UDFs) for Apache Pinot version 1.3.0.
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.
src/main/java/org/apache/pinot/common/function/scalar/
├── MyFunction.java # Example UDF implementation
- Java 21 or higher
- Apache Pinot 1.3.0
- Maven 3.6 or higher
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
-
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/
-
Restart all your Pinot components:
To add a new UDF:
- Create a new class in the
org.apache.pinot.common.function.scalar
package - Add the
@ScalarFunction
annotation to your method - Specify the function name(s) in the annotation, or default to the function name
- 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;
}
- 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