Support functions

The CREATE AGGREGATE statement expects information about four support functions. The following table summarizes these support functions. You must provide support functions for each data type that will use the aggregate.
INIT
Initializes the data structures required for computing the aggregate
ITER
Merges a single (row) value with the previous partial result
COMBINE
Merges one partial result with another partial result, thus allowing parallel execution of the aggregate
FINAL
Converts the partial result into the final value

It can perform cleanup operations and release resources.

You can write the support functions in SPL, C, or Java™. For information about SPL, refer to the HCL OneDB™ Guide to SQL: Syntax. For information about writing functions in external languages, refer to the HCL OneDB DataBlade® API Programmer's Guide or the HCL® J/Foundation Developer's Guide.

The following CREATE AGGREGATE statement registers the SUMSQ aggregate with support functions named init_func, iter_func, combine_func, and final_func. You can register an aggregate even though you have not yet written the support functions. ]
CREATE AGGREGATE sumsq
    (INIT = init_func,
     ITER = iter_func,
     COMBINE = combine_func,
     FINAL = final_func);

When you create a user-defined aggregate, you must overload each support function to provide for each data type on which the aggregate will operate. That is, if you create a new aggregate, SUMSQ, whose iterator function is iter_func, you must overload the iter_func function for each applicable data type. Aggregate names are not case sensitive. When you create and use an aggregate, you can use either uppercase or lowercase.