17.10 - getPhase() - Advanced SQL Engine - Teradata Database

Teradata Vantageā„¢ - SQL External Routine Programming

Advanced SQL Engine
Teradata Database
Release Number
Release Date
July 2021
Content Type
Programming Reference
Publication ID
English (United States)

Returns the current aggregation phase. The aggregation phase determines how to process the data passed in.

The return value is one of the Phase constants.

Value Meaning
Phase.AGR_INIT This is the first time Vantage invokes the aggregate UDF for an aggregation group.

For a window aggregate UDF, this phase is triggered once per partition at the start of a new aggregation group or first row.

The UDF must:
  • Allocate intermediate storage and initialize it.
  • Process the first detail passed into the UDF.
Phase.AGR_DETAIL This phase is triggered every time the forward row progresses.

In this phase, Vantage calls the UDF once for each row to be aggregated for each group.

The UDF must combine the input data with the intermediate storage defined for the group.

Phase.AGR_COMBINE This phase combines results from different AMPs for a specific group.

The UDF must combine the data for the two intermediate storage areas passed in.

This phase is not applicable for window aggregate UDFs.

Phase.AGR_MOVINGTRAIL This phase is only applicable for window aggregate UDFs for the moving window type (noncumulative, nonreporting window type).

This phase is triggered by the last few rows of a moving window when the forward pointer to the window reaches the end of the group or end of the file.

The phase does not provide any row or value to the UDF, but it is mainly used to indicate to the UDF that we are reaching the end of the group or file.

The UDF can use this phase to adjust the necessary internal count or related values to reflect the actual size as the window diminishes towards the end of the group or file.

Phase.AGR_FINAL No more input is expected for the group. The UDF must produce the final result for the group.
Phase.AGR_NODATA This phase is only presented when there is absolutely no data to aggregate.