Github user icexelloss commented on a diff in the pull request:

    https://github.com/apache/spark/pull/19630#discussion_r150963595
  
    --- Diff: python/pyspark/sql/functions.py ---
    @@ -2279,7 +2172,38 @@ 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)
    +            eval_type = functionType.value
    +        elif returnType is not None and isinstance(returnType, 
PandasUDFType):
    +            # @pandas_udf(dataType, functionType)
    +            eval_type = returnType.value
    +        else:
    +            # @pandas_udf(dataType) or @pandas_udf(returnType=dataType)
    --- End diff --
    
    Yes, there is a test for this.


---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org

Reply via email to