Github user cloud-fan commented on a diff in the pull request:
https://github.com/apache/spark/pull/19630#discussion_r148804761
--- Diff: python/pyspark/sql/functions.py ---
@@ -2279,7 +2174,36 @@ def pandas_udf(f=None, returnType=StringType()):
.. note:: The user-defined function must be deterministic.
"""
- return _create_udf(f, returnType=returnType,
pythonUdfType=PythonUdfType.PANDAS_UDF)
+ # decorator @pandas_udf(dataType(), functionType)
+ if f is None or isinstance(f, (str, DataType)):
+ # If DataType has been passed as a positional argument
+ # for decorator use it as a returnType
+
+ return_type = f or returnType
+
+ if return_type is None:
+ raise ValueError("Must specify return type.")
+
+ if functionType is not None:
+ # @pandas_udf(dataType, functionType=functionType)
+ # @pandas_udf(returnType=dataType, functionType=functionType)
+ udf_type = functionType
+ elif returnType is not None and isinstance(returnType, int):
--- End diff --
I'm a little confused by this branch, do you mean the `returnType` can
actually be `udfType` here?
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]