You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Some Flink SQL pipelines consume emitted changelog payloads as independent events. An aggregate update emits an old and a new payload, and downstream consumers retain and count both positively. For example, +I(value=0), -U(value=0), +U(value=1000) must become three stored append events, including two copies of value 0.
Paimon's ordinary append writer rejects retract records, filtering retracts loses required payloads, and a keyed table maintains relational state. Migrating a message-based pipeline with this event-retention requirement currently needs a custom conversion operator.
This PR adds sink.changelog-as-append, a default-off Flink SQL sink mode that stores each received INSERT, UPDATE_BEFORE, UPDATE_AFTER, and DELETE payload as an independent INSERT event.
Feedback is welcome on the SQL sink approach, physical fields versus writable metadata, and whether existing audit-log or changelog options can provide equivalent retention and conversion-time semantics.
Changes
Request the full changelog, including before-images and full deletes where available.
Deep-copy each payload before the existing append writer, preserving duplicates and protecting against object reuse. Populate configured nullable physical STRING/BIGINT fields with the original row kind and conversion-time epoch milliseconds before evaluating omitted physical generated columns. A partition expression such as LOWER(original_kind) therefore uses the stored row kind. Review discussion
Preserve upstream parallelism and its configured flag through materialization and generated-column evaluation, avoiding extra converters, writers and a rebalance after single-parallelism operators such as global aggregates.
Validate the mode for non-keyed file-store tables. Reject format tables and writes delegated to a lake-stream store at sink creation. Reject payload defaults because the append writer would replace received NULLs, and reject ignore-update-before because the mode retains before-images. Overwrite, ignore-delete, rowkind.field, key-only deletes, and direct partitioning by the metadata fields are also unsupported. Follow-up review
Document the SQL example, restrictions and timestamp/replay contract in the append streaming guide and generated connector option reference.
Scope and tradeoffs
The mode covers the Flink SQL table sink. DELETE and UPDATE_BEFORE become recorded data and do not remove earlier events; readers see INSERT records and can inspect the original kind field. The option is disabled by default, and the existing core append-writer guards remain in place.
Conversion time is neither source event time nor checkpoint commit time. Replay can assign new timestamps and move records to different downstream windows; timestamps are not globally ordered across subtasks. The sink preserves records delivered to it and cannot reconstruct history omitted upstream. Retaining all changes increases stored record volume compared with keyed state.
Tests
Rebased onto Apache Paimon master at f1b735b7f1. Focused Maven verify passed on Java 11 with Flink 1.20.1 and Flink 2.2.0, with 94 test cases per profile. Spotless and git diff --check passed, and the generated option reference matches the connector description.
The checkpoint recovery test commits an initial row, injects a failure after emitting uncheckpointed changes, and verifies the exact committed payloads after replay, including all four original row kinds and both identical INSERTs. It allows conversion timestamps to be reassigned. The generated-column tests cover partitioning by stored kind, deriving a column from conversion time, and filling an omitted generated metadata field. GitHub CI checks
Validation before the rebase
Local verification at f8054a0e6, based on upstream master at df43423, using Java 11:
Flink version / profile
Result
1.20.1 / flink1
26 passed; zero failures, errors or skips
2.2.0 / flink2
26 passed; zero failures, errors or skips, after clean recompilation
Each run covered ChangelogAsAppendTest (5), ChangelogAsAppendSinkTest (8), ChangelogAsAppendITCase (3), ChangelogModeTest (6), the existing append-writer DELETE/UPDATE_BEFORE rejection cases (2), and FormatTableITCase#testRejectChangelogAsAppend+testDiffFormat (2). There were 52 test executions total.
Coverage includes:
Converter: all four kinds, equal duplicates, null payloads, nested object reuse, generated-field validation, timestamp bounds and input immutability.
Sink: full changelog negotiation, unchanged defaults, incompatible tables/options, generated partition fields, overwrite validation after abilities are applied, and preservation of input parallelism with either configured-flag value.
SQL integration: explicit four-kind input and a real aggregate generating before-images, after-images and a final delete. Tests read committed storage and assert exact payload counts, duplicate retention, original kinds, INSERT read semantics and conversion-time bounds.
Regressions: REST-catalog batch SQL rejects the unsupported format-table option during sink creation; normal parquet/CSV/JSON writes still succeed. A global aggregate with job parallelism four retains one converter and one writer with FORWARD edges. Default changelog negotiation and append-writer retract rejection remain covered.
The format-table rejection and parallelism tests were first run against 514da05, where they reproduced both issues fixed by f8054a0. The focused Maven runs kept Checkstyle, Spotless and Enforcer enabled; git diff --check passed.
Earlier verification at 514da05: the connector/documentation module dependency closure built successfully with -Pflink2,spark3 -pl paimon-flink/paimon-flink-common,paimon-docs -am install -DskipTests. Checkstyle, Spotless, Enforcer and license checks were enabled in local Maven build/test invocations. Generated connector documentation succeeded with -Pflink2,spark3,generate-docs -pl paimon-docs package -DskipTests; git diff --check passed.
Upstream CI passed every job at f8054a0 except Python, which was skipped. This included JDK 8 and 11, Flink 1 and Flink 2 (with the 1.16–1.20 and 2.0–2.2 modules), end-to-end tests, documentation and licensing. The Flink 1 common job (JDK 8) and the Flink 2 job (JDK 11) each ran ChangelogAsAppendTest (5), ChangelogAsAppendSinkTest (8), ChangelogAsAppendITCase (3), ChangelogModeTest (6) and FormatTableITCase (8) with no failures.
df428bf replaces the deprecated fromCollection call in ChangelogAsAppendSinkTest with StreamExecutionEnvironmentUtils.fromData, removing the only compiler warning in the changed files. The class passed locally under flink1 and flink2 (8 tests each, Java 11) with Checkstyle and Spotless enabled.
Remaining validation includes the following.
Streaming reads and compaction retention coverage for the agreed contract.
Application-specific end-to-end parity and adoption checks.
Replace the deprecated StreamExecutionEnvironment#fromCollection call with
the version-compatible StreamExecutionEnvironmentUtils.fromData helper.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
The reason will be displayed to describe this comment to others. Learn more.
🟡 Changes recommended
Metadata is populated after generated-column evaluation, causing dependent columns to retain placeholder values and potentially route events to incorrect partitions.
The new SQL tests use bounded inputs and never restart, so they do not exercise event retention across checkpoint recovery. Add a streaming failover test that replays all four kinds and equal payloads, then asserts committed event counts without losses or extra events while allowing replayed rows to receive new conversion timestamps.
Reject ignore-update-before when changelog materialization is enabled
With ignore-update-before=true, materialization changes before-images to INSERT before the writer's row-kind filter runs, so the configured filter silently stops working. Reject this combination alongside ignore-delete=true and add a rejection test. Update the restriction lists in FlinkConnectorOptions, the generated reference and streaming.mdx as well.
Reject delegated lake-stream writes, payload defaults, and ignore-update-before when changelog materialization is enabled. Cover recovery with a checkpointed source that replays all row kinds and duplicate payloads. Use separate valid schemas for the generated-column regressions.
The reason will be displayed to describe this comment to others. Learn more.
Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.
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
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.
Purpose
Some Flink SQL pipelines consume emitted changelog payloads as independent events. An aggregate update emits an old and a new payload, and downstream consumers retain and count both positively. For example,
+I(value=0), -U(value=0), +U(value=1000)must become three stored append events, including two copies of value 0.Paimon's ordinary append writer rejects retract records, filtering retracts loses required payloads, and a keyed table maintains relational state. Migrating a message-based pipeline with this event-retention requirement currently needs a custom conversion operator.
This PR adds
sink.changelog-as-append, a default-off Flink SQL sink mode that stores each received INSERT, UPDATE_BEFORE, UPDATE_AFTER, and DELETE payload as an independent INSERT event.The feature request describes the event-retention contract and the proposed SQL interface. Support opt-in changelog-to-append materialization in Flink SQL
Feedback is welcome on the SQL sink approach, physical fields versus writable metadata, and whether existing audit-log or changelog options can provide equivalent retention and conversion-time semantics.
Changes
LOWER(original_kind)therefore uses the stored row kind. Review discussionignore-update-beforebecause the mode retains before-images. Overwrite,ignore-delete,rowkind.field, key-only deletes, and direct partitioning by the metadata fields are also unsupported. Follow-up reviewScope and tradeoffs
The mode covers the Flink SQL table sink. DELETE and UPDATE_BEFORE become recorded data and do not remove earlier events; readers see INSERT records and can inspect the original kind field. The option is disabled by default, and the existing core append-writer guards remain in place.
Conversion time is neither source event time nor checkpoint commit time. Replay can assign new timestamps and move records to different downstream windows; timestamps are not globally ordered across subtasks. The sink preserves records delivered to it and cannot reconstruct history omitted upstream. Retaining all changes increases stored record volume compared with keyed state.
Tests
Rebased onto Apache Paimon
masteratf1b735b7f1. Focused Mavenverifypassed on Java 11 with Flink 1.20.1 and Flink 2.2.0, with 94 test cases per profile. Spotless andgit diff --checkpassed, and the generated option reference matches the connector description.The checkpoint recovery test commits an initial row, injects a failure after emitting uncheckpointed changes, and verifies the exact committed payloads after replay, including all four original row kinds and both identical INSERTs. It allows conversion timestamps to be reassigned. The generated-column tests cover partitioning by stored kind, deriving a column from conversion time, and filling an omitted generated metadata field. GitHub CI checks
Validation before the rebase
Local verification at
f8054a0e6, based on upstreammasteratdf43423, using Java 11:flink1flink2Each run covered
ChangelogAsAppendTest(5),ChangelogAsAppendSinkTest(8),ChangelogAsAppendITCase(3),ChangelogModeTest(6), the existing append-writer DELETE/UPDATE_BEFORE rejection cases (2), andFormatTableITCase#testRejectChangelogAsAppend+testDiffFormat(2). There were 52 test executions total.Coverage includes:
The format-table rejection and parallelism tests were first run against
514da05, where they reproduced both issues fixed byf8054a0. The focused Maven runs kept Checkstyle, Spotless and Enforcer enabled;git diff --checkpassed.Earlier verification at
514da05: the connector/documentation module dependency closure built successfully with-Pflink2,spark3 -pl paimon-flink/paimon-flink-common,paimon-docs -am install -DskipTests. Checkstyle, Spotless, Enforcer and license checks were enabled in local Maven build/test invocations. Generated connector documentation succeeded with-Pflink2,spark3,generate-docs -pl paimon-docs package -DskipTests;git diff --checkpassed.Upstream CI passed every job at
f8054a0except Python, which was skipped. This included JDK 8 and 11, Flink 1 and Flink 2 (with the 1.16–1.20 and 2.0–2.2 modules), end-to-end tests, documentation and licensing. The Flink 1 common job (JDK 8) and the Flink 2 job (JDK 11) each ranChangelogAsAppendTest(5),ChangelogAsAppendSinkTest(8),ChangelogAsAppendITCase(3),ChangelogModeTest(6) andFormatTableITCase(8) with no failures.df428bfreplaces the deprecatedfromCollectioncall inChangelogAsAppendSinkTestwithStreamExecutionEnvironmentUtils.fromData, removing the only compiler warning in the changed files. The class passed locally underflink1andflink2(8 tests each, Java 11) with Checkstyle and Spotless enabled.Remaining validation includes the following.