-
Notifications
You must be signed in to change notification settings - Fork 29.2k
[SPARK-56686][SQL] Support streaming row-level CDC post-processing #55636
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
gengliangwang
wants to merge
7
commits into
apache:master
Choose a base branch
from
gengliangwang:streamingCDC
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
7ebdee6
[SPARK-56686][SQL] Support streaming row-level CDC post-processing
gengliangwang c1c94d1
Address review: clarify streaming CDC watermark semantics and consoli…
gengliangwang cb1e7ac
Expand Scaladoc on addStreamingRowLevelPostProcessing with plan diagr…
gengliangwang dee5e84
[SPARK-56686][SQL][FOLLOWUP] Address review on streaming CDC row-leve…
gengliangwang ffa0646
[SPARK-56686][SQL][FOLLOWUP] Tighten _commit_timestamp contract for s…
gengliangwang 7f471f2
[SPARK-56686][SQL][FOLLOWUP] Fix scalafmt and align Scaladoc with wat…
gengliangwang 791d5ce
[SPARK-56686][SQL][FOLLOWUP] Fail fast on NULL _commit_timestamp in s…
gengliangwang File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -35,8 +35,34 @@ | |
| * {@code update_preimage}, or {@code update_postimage}</li> | ||
| * <li>{@code _commit_version} (connector-defined type, e.g. LONG) — the version containing | ||
| * this change</li> | ||
| * <li>{@code _commit_timestamp} (TIMESTAMP) — the timestamp of the commit</li> | ||
| * <li>{@code _commit_timestamp} (TIMESTAMP) -- the timestamp of the commit. All rows | ||
| * belonging to a single {@code _commit_version} must share the same | ||
| * {@code _commit_timestamp}. For streaming reads with post-processing enabled, | ||
| * two additional requirements apply: | ||
| * <ol> | ||
| * <li>All rows of a single commit must appear in the same micro-batch (i.e. | ||
| * micro-batch boundaries align with commit boundaries).</li> | ||
| * <li>Distinct {@code _commit_version} values must have distinct | ||
| * {@code _commit_timestamp} values.</li> | ||
| * </ol> | ||
| * Streaming post-processing uses {@code _commit_timestamp} as event time with a | ||
| * zero-delay watermark, so once a micro-batch observes max event time T the | ||
| * global watermark advances to T. Both Spark's late-event filter and its | ||
| * state-eviction predicate then use {@code eventTime <= T} -- so any later row | ||
| * at exactly {@code _commit_timestamp = T} (whether from the same commit split | ||
| * across batches, or from a different commit that happens to share T) is | ||
| * silently dropped as late. Requirement 1 rules out the same-commit case; | ||
| * requirement 2 rules out the different-commit case. Atomic-commit CDC connectors | ||
| * (e.g. Delta versions, Iceberg snapshots) that derive {@code _commit_timestamp} | ||
| * from wall-clock time at commit time naturally satisfy both requirements. | ||
| * Behavior is undefined if {@code _commit_timestamp} is {@code NULL} on any row | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It says NULL behavior is “undefined,” but the latest code now intentionally raises CHANGELOG_CONTRACT_VIOLATION.NULL_COMMIT_TIMESTAMP. That doc should be updated to match the new fail-fast behavior. |
||
| * of a streaming read engaging post-processing -- a NULL group key never advances | ||
| * the watermark, which can stall emission of that group indefinitely</li> | ||
| * </ul> | ||
| * <p> | ||
| * Streaming reads support carry-over removal and update detection but not net change | ||
| * computation. The latter requires reasoning over the entire requested range and is | ||
| * batch-only. | ||
| * | ||
| * @since 4.2.0 | ||
| */ | ||
|
|
@@ -81,6 +107,12 @@ public interface Changelog { | |
| * Spark will collapse multiple changes per row identity into the net effect. | ||
| * If {@code false}, the connector guarantees at most one change per row identity across | ||
| * the entire changelog range, and Spark will skip net change computation. | ||
| * <p> | ||
| * Note this flag is range-scoped (across all commits in the request), not | ||
| * micro-batch-scoped. Streaming CDC reads currently reject | ||
| * {@code deduplicationMode = netChanges} because the per-row-identity collapse cannot | ||
| * be incrementalized: a row's full history may span an unbounded number of | ||
| * micro-batches. | ||
| */ | ||
| boolean containsIntermediateChanges(); | ||
|
|
||
|
|
||
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The new requirements fix the “same commit split across batches” case and the “same timestamp in later batch” case only if timestamps also arrive in increasing event-time order. But the doc no longer explicitly requires that every later micro-batch has _commit_timestamp greater than the previous watermark/max.
Example:
batch 1: commit v2, ts = 20
batch 2: commit v3, ts = 10
Timestamps are distinct, and each commit is atomic, but batch 2 is late after watermark 20. So the real required invariant is closer to: no later micro-batch may contain rows with _commit_timestamp <= previous max event time. Also, “distinct commit versions must have distinct timestamps” is stronger than necessary and may be unrealistic for ms-resolution commit timestamps; equal timestamps are safe if all such commits are emitted before the watermark advances.