[SPARK-55147][SS] Scope timestamp range for time-interval join retrieval in V4 state format#54879
Open
nicholaschew11 wants to merge 1 commit intoapache:masterfrom
Open
[SPARK-55147][SS] Scope timestamp range for time-interval join retrieval in V4 state format#54879nicholaschew11 wants to merge 1 commit intoapache:masterfrom
nicholaschew11 wants to merge 1 commit intoapache:masterfrom
Conversation
7935015 to
bde2f50
Compare
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 improves the retrieval operation in the V4 stream-stream join state manager to scope the timestamp range for time-interval joins. Instead of scanning all timestamps for a given key during prefix scan, V4 now extracts constant interval offsets from the join condition and computes a
(minTs, maxTs)range per input row, enabling the prefix scan to skip entries beforeminTsand terminate early pastmaxTs.scanRangeOffsetsandcomputeTimestampRangetoOneSideHashJoiner, usingStreamingJoinHelper.getStateValueWatermark(eventWatermark=0)to extract interval bounds from the join conditiontimestampRangeparameter togetJoinedRowsin the state manager trait, V4 implementation, and V1-V3 base class (ignored by V1-V3)getValuesInRangetoKeyWithTsToValuesStorethat filters by range and stops early past the upper boundgetValuesnow delegates togetValuesInRange(Long.MinValue, Long.MaxValue)Why are the changes needed?
For time-interval joins, the V4 state format stores values indexed by
(key, timestamp). Without range scoping, retrieving matches requires scanning all timestamps for a key via prefix scan, even though the join condition constrains matching to a specific time window. With this change, the scan is bounded to only the relevant timestamp range, reducing I/O proportionally to the ratio of the interval width to the total timestamp span in state.Does this PR introduce any user-facing change?
No. V4 state format is experimental and gated behind
spark.sql.streaming.join.stateFormatV4.enabled.How was this patch tested?
New unit tests in
SymmetricHashJoinStateManagerEventTimeInValueSuite:getJoinedRows with timestampRange: boundary conditions, exact matches, empty ranges, full rangetimestampRange with multiple values per timestamp: multiple values at the same timestampExisting V4 join suites (Inner, Outer, FullOuter, LeftSemi) all pass.
Was this patch authored or co-authored using generative AI tooling?
Yes. (Claude Opus 4.6)