An alternative to getPhase() that provides additional options for variable mode table UDFs. getPhaseEx() provides a way for table functions to know when they are being passed in the last logical, or qualified row on an AMP. getPhaseEx() also provides users with more control of table phase transitions. Users can reduce the number of phase transitions required during execution of a table function, thus reducing the number of UDF invocations and improving table function performance.
The processing phases that getPhaseEx() can return depend on the mode:
Value | Meaning |
---|---|
Tbl.TBL_MODE_CONST | The table UDF arguments are constant. Although getPhaseEx() can be used successfully by a table function that is passed in constant arguments, it is most useful to a table function that is passed in variable arguments. |
Tbl.TBL_MODE_VARY | The table UDF arguments vary and are based on the rows produced by the correlated table specification in the SELECT statement. The table UDF might only be called on specific AMP vprocs in this mode. |
Syntax
getPhaseEx(int[] phase, int option)
Syntax Elements
- phase
- The processing phases that getPhaseEx() returns in the phase argument depend on the mode.
- option
- The following values are valid for the option argument only for variable mode table UDFs. These options are ignored if you specify them in a constant mode table UDF.
Options Value Description and Usage Tbl.TBL_NOOPTIONS 0 Indicates that no options are specified. Use this option when you only want to retrieve the processing phase in which the function was called.
Tbl.TBL_LASTROW 1 Allows a function to determine when it is being passed the last input row on an AMP. Use this option if your table function processes a set of input rows before returning an output row. You must set the EOF indicator when using TBL_LASTROW to signal the end of the processing when the last row has been encountered. The function then moves from the TBL_BUILD phase to the TBL_BUILD_EOF phase where the row is built.
Tbl.TBL_NEWROW 2 If this option is set and the phase is TBL_BUILD, the function is called with a new row with a phase of TBL_BUILD. Use this option when you want to get a new row on each function invocation.
If end of file, TBL_LASTROW or ProcessLastRow is true, then this option is ignored.
Tbl.TBL_NEWROW and Tbl.TBL_LASTROW 3 The behavior for both the TBL_NEWROW and TBL_LASTROW options are in effect. Tbl.TBL_NEWROWEOF 4 If this option is set, and the phase is TBL_BUILD and EOF is set, then the function is called with a new row with a phase of TBL_BUILD. Use this option when you want to get a new row when EOF is signaled.
If end of file, TBL_LASTROW or ProcessLastRow is true, then this option is ignored.
Tbl.TBL_NEWROWEOF and Tbl.TBL_LASTROW 5 The behavior for both the TBL_NEWROWEOF and TBL_LASTROW options are in effect.