dianfu commented on a change in pull request #13421:
URL: https://github.com/apache/flink/pull/13421#discussion_r492475798



##########
File path: flink-python/pyflink/table/udf.py
##########
@@ -421,3 +600,53 @@ def udtf(f=None, input_types=None, result_types=None, 
deterministic=None, name=N
                                  deterministic=deterministic, name=name)
     else:
         return _create_udtf(f, input_types, result_types, deterministic, name)
+
+
+def udaf(f: Union[Callable, UserDefinedFunction, Type] = None,
+         input_types: Union[List[DataType], DataType] = None, result_type: 
DataType = None,
+         accumulator_type: DataType = None, deterministic: bool = None, name: 
str = None,
+         func_type: str = "pandas") -> 
Union[UserDefinedAggregateFunctionWrapper, Callable]:
+    """
+    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()
+
+    :param f: user-defined aggregate function.
+    :type f: function or UserDefinedFunction or type

Review comment:
       can be removed

##########
File path: flink-python/pyflink/table/udf.py
##########
@@ -421,3 +600,53 @@ def udtf(f=None, input_types=None, result_types=None, 
deterministic=None, name=N
                                  deterministic=deterministic, name=name)
     else:
         return _create_udtf(f, input_types, result_types, deterministic, name)
+
+
+def udaf(f: Union[Callable, UserDefinedFunction, Type] = None,
+         input_types: Union[List[DataType], DataType] = None, result_type: 
DataType = None,
+         accumulator_type: DataType = None, deterministic: bool = None, name: 
str = None,
+         func_type: str = "pandas") -> 
Union[UserDefinedAggregateFunctionWrapper, Callable]:

Review comment:
       What about making the default value `general`?

##########
File path: flink-python/pyflink/table/udf.py
##########
@@ -361,26 +528,38 @@ def udf(f=None, input_types=None, result_type=None, 
deterministic=None, name=Non
     :type deterministic: bool
     :param name: the function name.
     :type name: str
-    :param udf_type: the type of the python function, available value: 
general, pandas,
+    :param func_type: the type of the python function, available value: 
general, pandas,
                      (default: general)
+    :type func_type: str
+    :param udf_type: the type of the python function, available value: 
general, pandas,
+                    (default: general)
     :type udf_type: str
     :return: UserDefinedScalarFunctionWrapper or function.
     :rtype: UserDefinedScalarFunctionWrapper or function
 
     .. versionadded:: 1.10.0
     """
-    if udf_type not in ('general', 'pandas'):
-        raise ValueError("The udf_type must be one of 'general, pandas', got 
%s." % udf_type)
+    if func_type not in ('general', 'pandas'):

Review comment:
       the warning should be moved after
   ```
       if udf_type:
           import warnings
           warnings.warn("The param udf_type is deprecated in 1.12. Use 
func_type instead.")
           func_type = udf_type
   ``` 




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to