-
Notifications
You must be signed in to change notification settings - Fork 28.9k
[SPARK-53538][SQL] ExpandExec
should initialize the unsafe projections
#52292
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
Closed
Conversation
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
HyukjinKwon
approved these changes
Sep 9, 2025
Merged to master. |
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.
Could you make backporting PRs, @bersprockets ?
bersprockets
added a commit
to bersprockets/spark
that referenced
this pull request
Sep 10, 2025
Change `ExpandExec#doExecute` to initialize the unsafe projections before using them. The unsafe projections might contain non-deterministic expressions, and non-deterministic expressions must be initialized before used. For example, see the test added by this PR (which is essentially the test right above it, except with whole-stage codegen turned off). In the case where the "split-updates" property is set to "true", `RewriteUpdateTable` will create an `Expand` operator with a set of projections, one of which will contain a nondeterministic expression (the assignment value). `ExpandExec` fails to initialize the derived `UnsafeProjection`s before using them, resulting in a `NullPointerException`: ``` [info] org.apache.spark.SparkException: Job aborted due to stage failure: Task 0 in stage 11.0 failed 1 times, most recent failure: Lost task 0.0 in stage 11.0 (TID 11) (10.0.0.101 executor driver): java.lang.NullPointerException: Cannot invoke "java.util.Random.nextDouble()" because "<parameter1>.mutableStateArray_0[0]" is null [info] at org.apache.spark.sql.catalyst.expressions.GeneratedClass$SpecificUnsafeProjection.writeFields_0_0$(Unknown Source) [info] at org.apache.spark.sql.catalyst.expressions.GeneratedClass$SpecificUnsafeProjection.apply(Unknown Source) [info] at org.apache.spark.sql.execution.ExpandExec$$anon$1.next(ExpandExec.scala:75) ... ``` No. New test. Closes apache#52292 from bersprockets/upd_del_oddity. Authored-by: Bruce Robbins <bersprockets@gmail.com> Signed-off-by: Hyukjin Kwon <gurwls223@apache.org>
dongjoon-hyun
pushed a commit
that referenced
this pull request
Sep 12, 2025
…jections ### What changes were proposed in this pull request? This PR back-ports #52292. Change `ExpandExec#doExecute` to initialize the unsafe projections before using them. ### Why are the changes needed? The unsafe projections might contain non-deterministic expressions, and non-deterministic expressions must be initialized before used. For example, see the test added by this PR (which is essentially the test right above it, except with whole-stage codegen turned off). In the case where the "split-updates" property is set to "true", `RewriteUpdateTable` will create an `Expand` operator with a set of projections, one of which will contain a nondeterministic expression (the assignment value). `ExpandExec` fails to initialize the derived `UnsafeProjection`s before using them, resulting in a `NullPointerException`: ``` [info] org.apache.spark.SparkException: Job aborted due to stage failure: Task 0 in stage 11.0 failed 1 times, most recent failure: Lost task 0.0 in stage 11.0 (TID 11) (10.0.0.101 executor driver): java.lang.NullPointerException: Cannot invoke "java.util.Random.nextDouble()" because "<parameter1>.mutableStateArray_0[0]" is null [info] at org.apache.spark.sql.catalyst.expressions.GeneratedClass$SpecificUnsafeProjection.writeFields_0_0$(Unknown Source) [info] at org.apache.spark.sql.catalyst.expressions.GeneratedClass$SpecificUnsafeProjection.apply(Unknown Source) [info] at org.apache.spark.sql.execution.ExpandExec$$anon$1.next(ExpandExec.scala:75) ... ``` ### Does this PR introduce _any_ user-facing change? No. ### How was this patch tested? New test. Closes #52319 from bersprockets/upd_del_oddity_br40. Authored-by: Bruce Robbins <bersprockets@gmail.com> 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?
Change
ExpandExec#doExecute
to initialize the unsafe projections before using them.Why are the changes needed?
The unsafe projections might contain non-deterministic expressions, and non-deterministic expressions must be initialized before used.
For example, see the test added by this PR (which is essentially the test right above it, except with whole-stage codegen turned off). In the case where the "split-updates" property is set to "true",
RewriteUpdateTable
will create anExpand
operator with a set of projections, one of which will contain a nondeterministic expression (the assignment value).ExpandExec
fails to initialize the derivedUnsafeProjection
s before using them, resulting in aNullPointerException
:Does this PR introduce any user-facing change?
No.
How was this patch tested?
New test.
Was this patch authored or co-authored using generative AI tooling?