UDAF/UDSF Module Definition - Aster Execution Engine

Teradata Aster® Developer Guide

Product
Aster Execution Engine
Release Number
7.00.02
Published
July 2017
Language
English (United States)
Last Update
2018-04-13
dita:mapPath
xnl1494366523182.ditamap
dita:ditavalPath
Generic_no_ie_no_tempfilter.ditaval
dita:id
ffu1489104705746
lifecycle
previous
Product Category
Software

A typical module definition is as follows:

/*
* SQL-MR function module definition
*/
SQLMR_FUNCTION_MODULE_BEGIN()
{
   SQLMR_FUNCTION_ENTRY("average")
   {
      entry->newAggregatorFunction =
      &average_newAggregator;
   }
}
SQLMR_FUNCTION_MODULE_END()

The string given to SQLMR_FUNCTION_ENTRY is the name of the function. Within the module definition block, assign the function pointer of the factory method (for example, &average_newAggregator in the example above) to the respective one of the following members of SqlmrFunctionEntry according to the type of your function.

  • For a scalar function:
    SqlmrErrorH (*newScalarFunction)(
       SqlmrTaskContextH taskContext,
       SqlmrRuntimeContractH contract,
       UdfScalarFunctionPointers* outPointers
    ) SQLMR_ERROR_RESULT;
  • For an aggregate function:
    SqlmrErrorH (*newAggregatorFunction)(
       SqlmrTaskContextH taskContext,
       SqlmrRuntimeContractH contract,
       UdfAggregatorFunctionPointers* outPointers
    ) SQLMR_ERROR_RESULT;
  • For a decomposable aggregate function:
    SqlmrErrorH (*newDecomposableAggregatorFunction)(
       SqlmrTaskContextH taskContext,
       SqlmrRuntimeContractH contract,
       UdfDecomposableAggregatorFunctionPointers* outPointers
    ) SQLMR_ERROR_RESULT;

It is good practice to also provide HelpInfo in the module definition. See HelpInfo for User Defined Functions.