Deploying and using UDFs

Writing your own functions

Presto has a guide to writing UDFs which can be found here. In the GeoSpock examples repository there are two example UDFs which cover scalar and aggregate functions.

Once you have written your UDFs, they need to be packaged in a jar file.

Using your UDFs in a SQL query

Once you have written your UDFs, they need to be packaged in a jar file and deployed in the system. Please contact your system administrator to deploy the jar file.

When writing your UDFs, you will have specified the sql command to type with either the @ScalarFunction or @AggregationFunction tags.

In the example UDFs these were @ScalarFunction("is_pasta") and @AggregationFunction("avg_between_limits"), and examples of the way to call these functions within SQL are as follows:

presto> SELECT is_pasta('pasta'), is_pasta('cabbage');
 _col0 | _col1 
-------+-------
 true  | false 
(1 row)
presto> SELECT avg_between_limits(overdraft, 100, 150) FROM geospock.default.banks;
 _col0 
-------
 115.5  
(1 row)