Repository navigation
[Spark 4] Group the streaming stateful ParDo by encoded key bytes to support null keys - #40516
Merged
Merged
Conversation
…support null keys A null Beam key became a null Spark grouping key and transformWithState failed with INTERNAL_ERROR_TWS. Grouping by the coder encoded key bytes is null safe and matches Beam key equality. Part of apache#36841.
Contributor
Author
|
R: @Abacn |
Contributor
|
Stopping reviewer notifications for this pull request: review requested by someone other than the bot, ceding control. If you'd like to restart, comment |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #40516 +/- ##
============================================
+ Coverage 56.16% 65.07% +8.90%
- Complexity 2288 13991 +11703
============================================
Files 1124 1728 +604
Lines 178336 108509 -69827
Branches 1489 11313 +9824
============================================
- Hits 100170 70610 -29560
+ Misses 75645 33690 -41955
- Partials 2521 4209 +1688
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Closed
1 task done
Abacn
self-requested a review
October 14, 2026 18:48
Abacn
reviewed
Oct 15, 2026
Abacn
left a comment
Contributor
There was a problem hiding this comment.
Thanks, just one minor comment
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
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.
The Spark 4 Structured Streaming stateful ParDo grouped by the Beam key object, so a null key (
VoidCoder,WithKeys.of((Void) null),Combine.globally) became a null Spark grouping key andtransformWithStatefailed withINTERNAL_ERROR_TWS"Implicit key not found in state store" on the first state access.The translator now groups by
CoderHelpers.toByteArray(key, keyCoder)withEncoders.BINARY(), andBeamStatefulProcessordecodes the key once perhandleInputRowsandhandleExpiredTimercall. Byte equality is Beam key equality,ParDoalready rejects non deterministic key coders for stateful DoFns, and keys with custom coders were already grouped as bytes throughEncoderHelpers.binaryEncoder.The grouping key state schema changes from the key type to
BinaryType, so a query restarted from a checkpoint written by #40281 or #40447 fails withSTATE_STORE_KEY_SCHEMA_NOT_COMPATIBLE. That code is unreleased.Per review, the structured streaming
CoderHelpersis merged into the commonorg.apache.beam.runners.spark.coders.CoderHelpers, so all structured streaming callers now encode in nested context.testNullKeyfails on master withINTERNAL_ERROR_TWSand passes with this change.Part of #36841.