Flink Sink: Add WriteObserver plugin interface for per-record metadata#15784
Open
herbherbherb wants to merge 6 commits intoapache:mainfrom
Open
Flink Sink: Add WriteObserver plugin interface for per-record metadata#15784herbherbherb wants to merge 6 commits intoapache:mainfrom
herbherbherb wants to merge 6 commits intoapache:mainfrom
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.
Closes #15783
Summary
Adds a
WriteObserverplugin interface toIcebergSink(Sink V2) that observes each record written and produces per-checkpoint metadata that flows through the entire sink pipeline (writer → serializer → aggregator → committer) to the Iceberg snapshot summary.Motivation
Users need to extract per-record metadata (e.g., watermark timestamps, data quality scores) at the writer level and attach it to the committed Iceberg snapshot. Currently there is no way to propagate custom metadata from the writer through the aggregator to the committer without subclassing multiple internal classes.
Changes
WriteObserver.java-- interface withobserve(RowData, SinkWriter.Context)anddefault Map<String, String> snapshotMetadata()WriteObserverMetadataHolder.java-- ThreadLocal holder for passing metadata through serialization boundariesIcebergSinkWriter-- calls observer per-record, collects metadata at checkpointWriteResultSerializer-- v2 format carries observer metadata alongside WriteResultIcebergWriteAggregator-- merges metadata from writer subtasksIcebergCommittable+IcebergCommittableSerializer-- v2 format with observer metadata (backward-compatible with v1)IcebergCommitter-- applies observer metadata as snapshot propertiesIcebergSink.Builder-- newwriteObserver()methodCompatibility