-
Notifications
You must be signed in to change notification settings - Fork 29k
[SPARK-44749][PYTHON][FOLLOWUP][TESTS] Add more tests for named arguments in Python UDTF #42490
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
dtenedor
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM if @allisonwang-db agrees 👍
allisonwang-db
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great! Thanks for the follow-up PR.
| @udtf | ||
| class TestUDTF: | ||
| @staticmethod | ||
| def analyze(a, b=None): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If b is a parameter with a default value (e.g 100), do we need to also assign a default value (e.g. None) here in the analyze method? If we directly use def analyze(a, b) does it throw an exception?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, if b here doesn't have a default value, it will raise an exception.
Both eval and analyze will be called with the same argument list.
So if eval takes a, analyze should also take a, if eval takes a, b, analyze should also take a, b, and so on.
It can be AnalyzeArgument with the correct parameters, or take **kwargs.
def analyze(a, b=AnalyzeArgument(StringType(), None, False)):def analyze(a, **kwargs):but taking AnalyzeArgument as default is not recommended if the data_type is a struct type, which could cause unexpected behavior similar to taking [] or {} as default.
|
Thanks! merging to master. |
…ents in Python UDTF ### What changes were proposed in this pull request? This is a follow-up of apache#42422. Adds more tests for named arguments in Python UDTF. ### Why are the changes needed? There are more cases to test. ### Does this PR introduce _any_ user-facing change? No. ### How was this patch tested? Added related tests. Closes apache#42490 from ueshin/issues/SPARK-44749/tests. Authored-by: Takuya UESHIN <[email protected]> Signed-off-by: Takuya UESHIN <[email protected]>
What changes were proposed in this pull request?
This is a follow-up of #42422.
Adds more tests for named arguments in Python UDTF.
Why are the changes needed?
There are more cases to test.
Does this PR introduce any user-facing change?
No.
How was this patch tested?
Added related tests.