public interface UDTF extends UDF
New UDTF classes need to inherit from this UDTF class.
Generates a variable number of output data points for a single input row or a single input window (time-based or size-based).
A complete UDTF needs to override at least the following methods:
beforeStart(UDFParameters, UDTFConfigurations)
transform(RowWindow, PointCollector) or transform(Row,
PointCollector)
1. UDF.validate(UDFParameterValidator) 2. beforeStart(UDFParameters,
UDTFConfigurations) 3. transform(RowWindow, PointCollector) or transform(Row, PointCollector) 4. terminate(PointCollector) 5. UDF.beforeDestroy()
The query engine will instantiate an independent UDTF instance for each udf query column, and different UDTF instances will not affect each other.
| 限定符和类型 | 方法和说明 |
|---|---|
void |
beforeStart(UDFParameters parameters,
UDTFConfigurations configurations)
This method is mainly used to customize UDTF.
|
default void |
terminate(PointCollector collector)
This method will be called once after all {@link UDTF#transform(Row, PointCollector) calls or
{@link UDTF#transform(RowWindow, PointCollector) calls have been executed.
|
default void |
transform(Row row,
PointCollector collector)
When the user specifies
RowByRowAccessStrategy to access the original data in UDTFConfigurations, this method will be called to process the transformation. |
default void |
transform(RowWindow rowWindow,
PointCollector collector)
When the user specifies
SlidingSizeWindowAccessStrategy or SlidingTimeWindowAccessStrategy to access the original data in UDTFConfigurations,
this method will be called to process the transformation. |
beforeDestroy, validatevoid beforeStart(UDFParameters parameters, UDTFConfigurations configurations) throws Exception
This method is called after the UDTF is instantiated and before the beginning of the transformation process.
parameters - used to parse the input parameters entered by the userconfigurations - used to set the required properties in the UDTFException - the user can throw errors if necessarydefault void transform(Row row, PointCollector collector) throws Exception
RowByRowAccessStrategy to access the original data in UDTFConfigurations, this method will be called to process the transformation. In a single UDF
query, this method may be called multiple times.row - original input data row (aligned by time)collector - used to collect output data pointsException - the user can throw errors if necessaryRowByRowAccessStrategydefault void transform(RowWindow rowWindow, PointCollector collector) throws Exception
SlidingSizeWindowAccessStrategy or SlidingTimeWindowAccessStrategy to access the original data in UDTFConfigurations,
this method will be called to process the transformation. In a single UDF query, this method
may be called multiple times.rowWindow - original input data window (rows inside the window are aligned by time)collector - used to collect output data pointsException - the user can throw errors if necessarySlidingSizeWindowAccessStrategy,
SlidingTimeWindowAccessStrategydefault void terminate(PointCollector collector) throws Exception
collector - used to collect output data pointsException - the user can throw errors if necessaryCopyright © 2022 The Apache Software Foundation. All rights reserved.