-
Notifications
You must be signed in to change notification settings - Fork 28.2k
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
[SPARK-49719][SQL] Make UUID
and SHUFFLE
accept integer seed
#48166
Closed
Conversation
This file contains 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
zhengruifeng
commented
Sep 19, 2024
@@ -81,6 +81,7 @@ trait ExpressionWithRandomSeed extends Expression { | |||
|
|||
private[catalyst] object ExpressionWithRandomSeed { | |||
def expressionToSeed(e: Expression, source: String): Option[Long] = e match { |
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.
this helper function is only used in uuid
and shuffle
for now
dongjoon-hyun
approved these changes
Sep 19, 2024
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.
+1, LGTM. Thank you, @zhengruifeng .
Merged to master.
attilapiros
pushed a commit
to attilapiros/spark
that referenced
this pull request
Oct 4, 2024
### What changes were proposed in this pull request? Make `UUID` and `SHUFFLE` accept integer `seed` ### Why are the changes needed? In most cases, `seed` accept both int and long, but `UUID` and `SHUFFLE` only accept long seed ```py In [1]: spark.sql("SELECT RAND(1L), RAND(1), SHUFFLE(array(1, 20, 3, 5), 1L), UUID(1L)").show() +------------------+------------------+---------------------------+--------------------+ | rand(1)| rand(1)|shuffle(array(1, 20, 3, 5))| uuid()| +------------------+------------------+---------------------------+--------------------+ |0.6363787615254752|0.6363787615254752| [20, 1, 3, 5]|1ced31d7-59ef-4bb...| +------------------+------------------+---------------------------+--------------------+ In [2]: spark.sql("SELECT UUID(1)").show() ... AnalysisException: [INVALID_PARAMETER_VALUE.LONG] The value of parameter(s) `seed` in `UUID` is invalid: expects a long literal, but got "1". SQLSTATE: 22023; line 1 pos 7 ... In [3]: spark.sql("SELECT SHUFFLE(array(1, 20, 3, 5), 1)").show() ... AnalysisException: [INVALID_PARAMETER_VALUE.LONG] The value of parameter(s) `seed` in `shuffle` is invalid: expects a long literal, but got "1". SQLSTATE: 22023; line 1 pos 7 ... ``` ### Does this PR introduce _any_ user-facing change? yes after this fix: ```py In [2]: spark.sql("SELECT SHUFFLE(array(1, 20, 3, 5), 1L), SHUFFLE(array(1, 20, 3, 5), 1), UUID(1L), UUID(1)").show() +---------------------------+---------------------------+--------------------+--------------------+ |shuffle(array(1, 20, 3, 5))|shuffle(array(1, 20, 3, 5))| uuid()| uuid()| +---------------------------+---------------------------+--------------------+--------------------+ | [20, 1, 3, 5]| [20, 1, 3, 5]|1ced31d7-59ef-4bb...|1ced31d7-59ef-4bb...| +---------------------------+---------------------------+--------------------+--------------------+ ``` ### How was this patch tested? added tests ### Was this patch authored or co-authored using generative AI tooling? no Closes apache#48166 from zhengruifeng/int_seed. Authored-by: Ruifeng Zheng <ruifengz@apache.org> Signed-off-by: Dongjoon Hyun <dongjoon@apache.org>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
What changes were proposed in this pull request?
Make
UUID
andSHUFFLE
accept integerseed
Why are the changes needed?
In most cases,
seed
accept both int and long, butUUID
andSHUFFLE
only accept long seedDoes this PR introduce any user-facing change?
yes
after this fix:
How was this patch tested?
added tests
Was this patch authored or co-authored using generative AI tooling?
no