Create and Add User-Defined Functions for RAQL Queries
You can define your own functions to use in
RAQL queries in addition to the
Built-In
RAQL
Functions. User-defined functions are Java classes that you write, configure and deploy to
Presto.
User-defined function can be:
Plain functions: used in Select, Over, Where, Order By and Group By clauses in
RAQL queries. They typically either
cast (change) the datatype of column values, extract part of the values or transform values in some way.
Plain functions are applied individually to each value in the column specified without access to values in other rows.
Window analytic functions: use some of the rows in a partition or window to perform a calculation and return a value for each row. Typically, this uses rows that are relative to the current row, such as
first_value or
row_number.
You must include an Over clause in queries that use window analytic functions. This defines the partitions or windows used by the function.
Aggregate analytic functions: use all rows in the dataset, group, partition or window to perform a calculation and return a single value. For example,
sum adds the values of all rows in the current scope.
Aggregate analytic functions can be be used in the Select or Having clauses of RAQL queries:
To return a single value for each group defined in a Group By clause.
To return a single value for each partition or each window defined in an Over clause. This single value is added to each row in the partition or window. You can also use aggregate analytic functions to return running calculations for partitions or windows defined in an Over clause.
To return a single value for the entire dataset if no group definition or partition definition is specified.
To write user-defined functions for
RAQL, you should
Set Up Your Development Environment. Then: