Github user holdenk commented on a diff in the pull request:
https://github.com/apache/spark/pull/16533#discussion_r97911634
--- 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()):
--- End diff --
Should we keep the since annotation? Also maybe explain what these params
are in the docstring (which can be based on the docstirng you currently have
for _udf but updated).
---
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]