getPhase() - Advanced SQL Engine - Teradata Database

SQL External Routine Programming

Product
Advanced SQL Engine
Teradata Database
Release Number
17.10
Published
July 2021
Language
English (United States)
Last Update
2021-07-27
dita:mapPath
rin1593638965306.ditamap
dita:ditavalPath
rin1593638965306.ditaval
dita:id
B035-1147
lifecycle
previous
Product Category
Teradata Vantageā„¢

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.