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

    https://github.com/apache/spark/pull/16533#discussion_r97911757
  
    --- Diff: python/pyspark/sql/functions.py ---
    @@ -1862,9 +1862,33 @@ def udf(f, returnType=StringType()):
         >>> slen = udf(lambda s: len(s), IntegerType())
         >>> df.select(slen(df.name).alias('slen')).collect()
         [Row(slen=5), Row(slen=3)]
    +    >>> @udf
    +    ... def to_upper(s):
    +    ...     if s is not None:
    +    ...         return s.upper()
    +    ...
    +    >>> @udf(returnType=IntegerType())
    +    ... def add_one(x):
    +    ...     if x is not None:
    +    ...         return x + 1
    +    ...
         """
         return UserDefinedFunction(f, returnType)
     
    +
    [email protected](_udf)
    +def udf(f=None, returnType=StringType()):
    +    """A decorator version of pyspark.sql.functions.udf
    +    """
    +    if f is None or isinstance(f, DataType):
    --- End diff --
    
    Maybe you can mention why this would be the case in the comment as well?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to