pyflink.table.udf.udaf#
- udaf(f: Optional[Union[Callable, pyflink.table.udf.AggregateFunction, Type]] = None, input_types: Optional[Union[List[pyflink.table.types.DataType], pyflink.table.types.DataType, str, List[str]]] = None, result_type: Optional[Union[pyflink.table.types.DataType, str]] = None, accumulator_type: Optional[Union[pyflink.table.types.DataType, str]] = None, deterministic: Optional[bool] = None, name: Optional[str] = None, func_type: str = 'general') Union[pyflink.table.udf.UserDefinedAggregateFunctionWrapper, Callable] [source]#
Helper method for creating a user-defined aggregate function.
- Example:
>>> # The input_types is optional. >>> @udaf(result_type=DataTypes.FLOAT(), func_type="pandas") ... def mean_udaf(v): ... return v.mean() >>> # Specify result_type via string >>> @udaf(result_type='FLOAT', func_type="pandas") ... def mean_udaf(v): ... return v.mean()
- Parameters
f – user-defined aggregate function.
input_types – optional, the input data types.
result_type – the result data type.
accumulator_type – optional, the accumulator data type.
deterministic – the determinism of the function’s results. True if and only if a call to this function is guaranteed to always return the same result given the same parameters. (default True)
name – the function name.
func_type – the type of the python function, available value: general, pandas, (default: general)
- Returns
UserDefinedAggregateFunctionWrapper or function.
New in version 1.12.0.