Repository navigation
[Spark 4] Support stateful ParDo in Structured Streaming via transformWithState - #40281
Conversation
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## master #40281 +/- ##
============================================
- Coverage 59.04% 58.74% -0.31%
+ Complexity 15624 13909 -1715
============================================
Files 2797 2584 -213
Lines 280750 271444 -9306
Branches 12488 11229 -1259
============================================
- Hits 165764 159454 -6310
+ Misses 108540 105996 -2544
+ Partials 6446 5994 -452
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:
|
|
Assigning reviewers: R: @damccorm added as fallback since no labels match configuration Note: If you would like to opt out of this review, comment Available commands:
The PR bot will only process comments in the main thread (not review comments). |
|
Stopping reviewer notifications for this pull request: review requested by someone other than the bot, ceding control. If you'd like to restart, comment |
Abacn
left a comment
There was a problem hiding this comment.
Thanks, again, could you please trigger PostCommit ValidateRunner Spark StructuredStreaming tests?
|
The PostCommit run is red, but master is red the same way since #40324 (scheduled runs from 2026-10-01 22:46, about 112 failures, "Expected 1 successful assertions, but found N"). The failing set differs randomly between runs and none of the stateful tests fail only here. It looks like the parallel test threads from #40324 make PAssert counters from concurrent pipelines add up on the Spark runner. |
…mWithState Stateful ParDo runs through Spark transformWithState. User state reuses SparkStateInternals over a MapState and timers reuse SparkTimerInternals persisted in a ValueState with one Spark wake up per key. Unsupported timer domains, window expiration, time sorted input and merging windows fail at translation naming apache#36841.
841f15c to
e13c345
Compare
|
Rebased on master with the Spark fix from #40428, PostCommit ValidatesRunner Spark StructuredStreaming is green now: https://github.com/apache/beam/actions/runs/37522104261 |
Part of #36841, slice 5b.
Stateful ParDo, with state and event time timers, now runs on the Spark 4 Structured Streaming runner through Spark 4
transformWithState. Before this change, the streaming translator rejected it.How it works
SparkStateInternals. A newStateCellsinterface lets it run on a SparkMapState. The existing callers keep the Table backed path.SparkTimerInternals. They are persisted per key in a SparkValueState. Each key gets one Spark timer as a wake up, at the earliest pending Beam timer plus 1 ms. Spark fires when the expiry is less than or equal to the watermark, and Beam fires only when the watermark is strictly after the timestamp, so the extra 1 ms matches the two rules. Timers fire one at a time, so a callback can still set or delete other timers.StatefulTaskRunner. That lifecycle covers setup on the executor, metrics, and teardown on task completion or failure.@OnWindowExpiration,@RequiresTimeSortedInput, and merging windows.Watermark semantics
The runner's input watermark is Spark's event time watermark, as set up in the earlier slices: max event time minus
--watermarkDelayMillis. Lateness and timer firing both follow that watermark. For out of order sources, raise the delay. Spark has no watermark hold for timer output timestamps. That is harmless while only stateless transforms follow, and it is tracked as a blocker for GroupByKey in 5c (#36841 comment).Tests
StatefulParDoStreamingTestruns a live query. It covers state across micro batches, timer firing, a callback that deletes a later due timer, and a checkpoint restart.PipelineTranslatorStreamingTesthas one table driven test for the rejected shapes.SparkStateInternalsTeststill pass on Spark 3 and Spark 4.CHANGES.md follows with GroupByKey in 5c. A ValidatesRunner suite follows once Impulse and PAssert are supported.