[SPARK-57228][SS] Support transformWithState in Real-Time Mode - #57979
Open
jerrypeng wants to merge 3 commits into
Open
[SPARK-57228][SS] Support transformWithState in Real-Time Mode#57979jerrypeng wants to merge 3 commits into
jerrypeng wants to merge 3 commits into
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
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?
This PR enables the JVM (Scala/Java)
transformWithStateoperator to run in Structured Streaming Real-Time Mode (RTM).The main changes are:
TransformWithStateExecin RTM and propagate the authoritative RTM flag fromIncrementalExecution, including batches where a source is temporarily replaced byLocalRelation.subsequent scans resume from the previous expiration threshold, and the final batch scan remains unbounded.
spark.sql.streaming.realTimeMode.transformWithState.ttlEvictionIntervalMscontrols the interval and defaults to one second.uncommitted retry attempt.
The public
transformWithStateAPI is unchanged. This PR is limited to the JVM implementation and does not enable PySparktransformWithStatein RTM.Why are the changes needed?
The existing
transformWithStateexecution path assumes a finite micro-batch:These assumptions do not hold for RTM. RTM uses long-running batches and pipelined shuffle, which does not provide the ordering required by grouped micro-batch processing. A fixed batch
timestamp and batch-end-only cleanup would also delay processing-time timers and TTL expiration for the duration of the RTM batch.
The recovery changes prevent an unsuccessful batch attempt from causing the next attempt to validate against uncommitted operator metadata.
Does this PR introduce any user-facing change?
Yes.
Previously, JVM
transformWithStatequeries usingTrigger.RealTimewere unsupported and rejected. With this PR, Scala and JavatransformWithStatequeries can run in RTM under theexisting RTM restrictions.
Processing-time timers and TTL state can expire while a long-running RTM batch remains open. Event-time watermarks continue to advance only between batches, while timers already expired
against the current batch watermark can fire incrementally as input arrives.
PySpark
transformWithStateremains unsupported in RTM.How was this patch tested?
The main RTM coverage was run with both the standard RocksDB configuration and row checksums enabled:
build/sbt \ 'sql/testOnly org.apache.spark.sql.streaming.RealTimeTransformWithStateSuite org.apache.spark.sql.streaming.RealTimeTransformWithStateSuiteWithRowChecksum'Additional review-driven validation included:
Coverage includes:
Was this patch authored or co-authored using generative AI tooling?
Co-authored with OpenAI Codex