addition-udf
What it does. Adds the numbers in a list and returns the total.
SELECT ADD(array(1, 2, 3)); -- 6.0Behaviour
Section titled “Behaviour”| Input | Result |
|---|---|
array(1, 2, 3) |
6.0 |
array(1, NULL, 3) |
4.0 (empty values are skipped) |
array() or only NULL values |
NULL |
NULL |
NULL |
The result is a DOUBLE, so very large whole numbers and some decimals can lose precision.
How it works
Section titled “How it works”AdditionUdf implements the SparkUdf contract. getName() returns ADD. register() hands Spark a function that walks the array once, skips empty values and keeps a running total. The class is registered for discovery with @AutoService, so no service file needs to be written by hand.
Add it to a build
Section titled “Add it to a build”<dependency> <groupId>com.camelioflux.plugins.udf</groupId> <artifactId>addition-udf</artifactId> <version>1.0.0</version></dependency>implementation("com.camelioflux.plugins.udf:addition-udf:1.0.0")spark-submit --jars core-udf-1.0.0.jar,addition-udf-1.0.0.jar ...Versions
Section titled “Versions”| Version | Released | Javadoc | Links |
|---|---|---|---|
1.0.0latest | 2026-12-05 | This site | Maven Central · Source |
0.0.1-test1test | 2026-12-05 | javadoc.io | Maven Central · Source |
- Source: gitlab.com/camelioflux/plugins/user-defined-function-plugins/addition-udf
- Build file:
pom.xml
