Skip to content

Commit 784b942

Browse files
ueshinHyukjinKwon
authored andcommitted
[SPARK-44380][PYTHON][FOLLOWUP] Set __doc__ for analyze static method when Arrow is enabled
### What changes were proposed in this pull request? This is a follow-up of apache#41948. Set `__doc__` for `analyze` static method when Arrow is enabled. ### Why are the changes needed? When Arrow is enabled, `analyze` static method doesn't have `__doc__` that should be the same as the original contents. ### Does this PR introduce _any_ user-facing change? No. ### How was this patch tested? Updated the related tests. Closes apache#42111 from ueshin/issues/SPARK-44380/analyze_doc. Authored-by: Takuya UESHIN <[email protected]> Signed-off-by: Hyukjin Kwon <[email protected]>
1 parent 09c44fd commit 784b942

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

python/pyspark/sql/tests/test_udtf.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -749,6 +749,11 @@ def __init__(self):
749749
"""Initialize the UDTF"""
750750
...
751751

752+
@staticmethod
753+
def analyze(x: AnalyzeArgument) -> AnalyzeResult:
754+
"""Analyze the argument."""
755+
...
756+
752757
def eval(self, x: int):
753758
"""Evaluate the input row."""
754759
yield x + 1,
@@ -757,9 +762,10 @@ def terminate(self):
757762
"""Terminate the UDTF."""
758763
...
759764

760-
cls = udtf(TestUDTF, returnType="y: int").func
765+
cls = udtf(TestUDTF).func
761766
self.assertIn("A UDTF for test", cls.__doc__)
762767
self.assertIn("Initialize the UDTF", cls.__init__.__doc__)
768+
self.assertIn("Analyze the argument", cls.analyze.__doc__)
763769
self.assertIn("Evaluate the input row", cls.eval.__doc__)
764770
self.assertIn("Terminate the UDTF", cls.terminate.__doc__)
765771

python/pyspark/sql/udtf.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,9 @@ def terminate(self) -> Iterator[pd.DataFrame]:
178178
if hasattr(cls, "terminate"):
179179
getattr(vectorized_udtf, "terminate").__doc__ = getattr(cls, "terminate").__doc__
180180

181+
if hasattr(vectorized_udtf, "analyze"):
182+
getattr(vectorized_udtf, "analyze").__doc__ = getattr(cls, "analyze").__doc__
183+
181184
return vectorized_udtf
182185

183186

0 commit comments

Comments
 (0)