Repository navigation
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.
|
R: @Abacn |
|
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.02% +8.85%
- Complexity 2288 13952 +11664
============================================
Files 1124 1728 +604
Lines 178336 108384 -69952
Branches 1489 11286 +9797
============================================
- Hits 100170 70478 -29692
+ Misses 75645 33703 -41942
- Partials 2521 4203 +1682
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:
|
Abacn
left a comment
There was a problem hiding this comment.
Thanks, just one minor comment
| */ | ||
| package org.apache.beam.runners.spark.structuredstreaming.translation.streaming; | ||
|
|
||
| import org.apache.beam.runners.spark.coders.CoderHelpers; |
There was a problem hiding this comment.
Realize there is a org.apache.beam.runners.spark.structuredstreaming.translation.helpers.CoderHelpers used by ReadUnboundedTranslator and etc. Consider deduplicate the class (merge structuredstreaming one into the common one)
There was a problem hiding this comment.
Switched both stateful files to the structured streaming CoderHelpers in 5608646, so that package no longer imports the legacy one. I did not merge the classes here: the legacy class encodes in nested context (coder.encode(value, stream)) and the structured streaming one in outer context (CoderUtils), and the latter encodes the unbounded source checkpoint marks that shipped in 2.77.0, so folding one into the other changes persisted bytes. Happy to do the dedup in a follow up that keeps the outer encoding for the structured streaming callers.
There was a problem hiding this comment.
If the concern is compatibility it's fine. The code exists in Beam 2.77 but until validate runner running and we announce it in CHANGS.md, Spark4 DataSet API Streaming is considered incomplete and not usable in production yet
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, and the stateful path now uses the structured streamingCoderHelpers(outer context) for keys and timers, so a query restarted from a checkpoint written by #40281 or #40447 fails withSTATE_STORE_KEY_SCHEMA_NOT_COMPATIBLE. That code is unreleased.testNullKeyfails on master withINTERNAL_ERROR_TWSand passes with this change.Part of #36841.