-
Notifications
You must be signed in to change notification settings - Fork 29k
[SPARK-25328][PYTHON] Add an example for having two columns as the grouping key in group aggregate pandas UDF #22329
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
…gregate pandas UDF
|
Test build #95666 has finished for PR 22329 at commit
|
python/pyspark/sql/functions.py
Outdated
| | 1|1.5| | ||
| | 2|6.0| | ||
| +---+---+ | ||
| >>> @pandas_udf("id long, v1 double, v2 double", PandasUDFType.GROUPED_MAP) # doctest: +SKIP |
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.
It took me a while to realize v1 is a grouping key. It also a bit uncommon to use double value as a grouping key . How about we do sth like?
id long, additional_key long, v double
|
Test build #95690 has finished for PR 22329 at commit
|
|
cc @gatorsmile and @BryanCutler |
python/pyspark/sql/functions.py
Outdated
| | 2|6.0| | ||
| +---+---+ | ||
| >>> @pandas_udf( | ||
| ... "id long, additional_key double, v double", |
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.
do you mind changing the type of additional_key to long? It seems like the type coercion here is not necessary.
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.
Sorry, I know you just changed it, but I think just naming the column "ceil(v1 / 2)" with a type long would be a little more clear. Although "additional_key" is ok too, if you guys want to keep that.
|
Test build #95734 has finished for PR 22329 at commit
|
BryanCutler
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
|
LGTM |
|
merged to master, thanks @HyukjinKwon . I just saw branch-2.4 was cut already, I'll see if I can figure out how to merge there too. |
…ouping key in group aggregate pandas UDF ## What changes were proposed in this pull request? This PR proposes to add another example for multiple grouping key in group aggregate pandas UDF since this feature could make users still confused. ## How was this patch tested? Manually tested and documentation built. Closes #22329 from HyukjinKwon/SPARK-25328. Authored-by: hyukjinkwon <[email protected]> Signed-off-by: Bryan Cutler <[email protected]> (cherry picked from commit 7ef6d1d) Signed-off-by: Bryan Cutler <[email protected]>
|
merged to branch-2.4 |
|
Thanks guys :-) |
What changes were proposed in this pull request?
This PR proposes to add another example for multiple grouping key in group aggregate pandas UDF since this feature could make users still confused.
How was this patch tested?
Manually tested and documentation built.