You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@spark.apache.org by li...@apache.org on 2018/01/06 15:08:41 UTC
spark git commit: [SPARK-22901][PYTHON][FOLLOWUP] Adds the doc for
asNondeterministic for wrapped UDF function
Repository: spark
Updated Branches:
refs/heads/master 7b7804142 -> 993f21567
[SPARK-22901][PYTHON][FOLLOWUP] Adds the doc for asNondeterministic for wrapped UDF function
## What changes were proposed in this pull request?
This PR wraps the `asNondeterministic` attribute in the wrapped UDF function to set the docstring properly.
```python
from pyspark.sql.functions import udf
help(udf(lambda x: x).asNondeterministic)
```
Before:
```
Help on function <lambda> in module pyspark.sql.udf:
<lambda> lambda
(END
```
After:
```
Help on function asNondeterministic in module pyspark.sql.udf:
asNondeterministic()
Updates UserDefinedFunction to nondeterministic.
.. versionadded:: 2.3
(END)
```
## How was this patch tested?
Manually tested and a simple test was added.
Author: hyukjinkwon <gu...@gmail.com>
Closes #20173 from HyukjinKwon/SPARK-22901-followup.
Project: http://git-wip-us.apache.org/repos/asf/spark/repo
Commit: http://git-wip-us.apache.org/repos/asf/spark/commit/993f2156
Tree: http://git-wip-us.apache.org/repos/asf/spark/tree/993f2156
Diff: http://git-wip-us.apache.org/repos/asf/spark/diff/993f2156
Branch: refs/heads/master
Commit: 993f21567a1dd33e43ef9a626e0ddfbe46f83f93
Parents: 7b78041
Author: hyukjinkwon <gu...@gmail.com>
Authored: Sat Jan 6 23:08:26 2018 +0800
Committer: gatorsmile <ga...@gmail.com>
Committed: Sat Jan 6 23:08:26 2018 +0800
----------------------------------------------------------------------
python/pyspark/sql/tests.py | 1 +
python/pyspark/sql/udf.py | 4 ++--
2 files changed, 3 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/spark/blob/993f2156/python/pyspark/sql/tests.py
----------------------------------------------------------------------
diff --git a/python/pyspark/sql/tests.py b/python/pyspark/sql/tests.py
index 689736d..122a65b 100644
--- a/python/pyspark/sql/tests.py
+++ b/python/pyspark/sql/tests.py
@@ -413,6 +413,7 @@ class SQLTests(ReusedSQLTestCase):
pydoc.render_doc(udf(lambda: random.randint(6, 6), IntegerType()))
pydoc.render_doc(random_udf)
pydoc.render_doc(random_udf1)
+ pydoc.render_doc(udf(lambda x: x).asNondeterministic)
def test_nondeterministic_udf_in_aggregate(self):
from pyspark.sql.functions import udf, sum
http://git-wip-us.apache.org/repos/asf/spark/blob/993f2156/python/pyspark/sql/udf.py
----------------------------------------------------------------------
diff --git a/python/pyspark/sql/udf.py b/python/pyspark/sql/udf.py
index 5e75eb6..5e80ab9 100644
--- a/python/pyspark/sql/udf.py
+++ b/python/pyspark/sql/udf.py
@@ -169,8 +169,8 @@ class UserDefinedFunction(object):
wrapper.returnType = self.returnType
wrapper.evalType = self.evalType
wrapper.deterministic = self.deterministic
- wrapper.asNondeterministic = lambda: self.asNondeterministic()._wrapped()
-
+ wrapper.asNondeterministic = functools.wraps(
+ self.asNondeterministic)(lambda: self.asNondeterministic()._wrapped())
return wrapper
def asNondeterministic(self):
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@spark.apache.org
For additional commands, e-mail: commits-help@spark.apache.org