pyflink.table.udf.udaf#
- udaf(f: Callable | AggregateFunction | Type, input_types: List[DataType] | DataType | str | List[str] | None = None, result_type: DataType | str | None = None, accumulator_type: DataType | str | None = None, deterministic: bool | None = None, name: str | None = None, func_type: str = 'general') UserDefinedAggregateFunctionWrapper[source]#
- udaf(f: None = None, input_types: List[DataType] | DataType | str | List[str] | None = None, result_type: DataType | str | None = None, accumulator_type: DataType | str | None = None, deterministic: bool | None = None, name: str | None = None, func_type: str = 'general') Callable[[Callable | AggregateFunction | Type], UserDefinedAggregateFunctionWrapper]
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.
Added in version 1.12.0.