-
Notifications
You must be signed in to change notification settings - Fork 29.3k
[SPARK-58500][PYTHON] Accept tuple in DataFrame.describe and selectExpr #57702
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
Open
Spenserrrr
wants to merge
1
commit into
apache:master
Choose a base branch
from
Spenserrrr:list-widening
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
I feel like we shouldn't allow this case explicitly. I know the support was already there but adding the corresponding type hints means that we will officially support this.
I would rather just issue a deprecated warning or sth.
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.
Are there a lot of API that supports a tuple? or only selectExpr and describe are all?
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.
What's your take @gaogaotiantian ?
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.
Thank you so much for taking a look, @HyukjinKwon!
This is one of the three related PRs on cleaning up the pattern that varargs also accepts a single sequence, so I think this question applies to all three as well. The other two PR: #57693, #57726.
Also, these PRs are suggested by Tian's comment on #57611, and he suggested handling this pattern at the repo level, and he pointed me to his #54764 as a reference. He widened
ListtoSequenceand added the two overloads. So that's the pattern I followed here to make these consistent with what is already indataframe.py.For how widespread this is, on the current master, the single-collection form is already accepted at around a dozen places. For example, partitionBy/clusterBy on the writers and stream writers (classic and connect), and struct/create_map/array/map_concat, which takes a list or a set (and in connect a tuple too, so a tuple works in connect but not classic for the same public function today). And in dataframe.py, select/groupBy/rollup/cube/sort/sortWithinPartitions already carry the Sequence[...] annotation and the two overloads from Tian's edit.
Also, a quick summary of my PRs: #57693 only corrects annotations for the writer methods, which already accept list and tuple; this PR and #57726 widen list-only sites, which do add tuple support; and I plan to create another PR for struct/create_map/array/map_concat because a set isn't a Sequence and classic/connect disagree there.