[Fix][Connector-V2] Fix Paimon branch save mode DDL#10991
Open
QuakeWang wants to merge 1 commit into
Open
Conversation
DanielLeens
reviewed
Jun 2, 2026
Contributor
DanielLeens
left a comment
There was a problem hiding this comment.
Thanks for working on this. I reviewed the latest head from scratch and traced the non-main-branch save-mode path through both the save-mode guard and the schema-evolution handler.
What this PR solves
- User pain: when writing to a non-main Paimon branch, destructive save modes or schema evolution can accidentally operate on the main table instead of the target branch.
- Fix approach: fail fast on unsafe branch save modes, require the main table and target branch to exist first, and route branch schema changes to a branch-aware Paimon identifier.
- One-line summary: the latest head closes the branch/main-table safety gap cleanly, and I did not find a new blocker on this path.
Runtime path I checked
save-mode guard
-> PaimonSaveModeHandler.handleSchemaSaveMode() [59-72]
-> checkBranchSaveMode() [91-115]
-> require main table exists
-> require target branch exists
-> reject RECREATE_SCHEMA / DROP_DATA on non-main branches
schema evolution path
-> PaimonSinkWriter.applySchemaChange(...)
-> AlterPaimonTableSchemaEventHandler.toIdentifier() [136-143]
-> uses Identifier(database, table, branch) for non-main branch
test coverage
-> PaimonBranchSaveModeHandlerTest
-> destructive branch save modes fail
-> branch schema change does not mutate the main schema
Review result
PaimonSaveModeHandler.java:91-115now blocks the dangerous cases I was looking for:- no implicit main-table auto-create for branch writes,
- no implicit branch auto-create,
- no
RECREATE_SCHEMA/DROP_DATAon a non-main branch.
AlterPaimonTableSchemaEventHandler.java:136-143is the key correctness change for schema evolution: branch updates now target the branch identifier directly instead of falling back to the main table.PaimonBranchSaveModeHandlerTest.java:92-256covers the important user-facing cases, including the “branch-only schema change must not touch the main schema” path.- I did not find a new source-level blocker on the latest head.
Tests / CI
- The new tests are targeted and structurally stable.
- I did not see a flaky-test pattern in the added coverage.
- The current GitHub
Buildis green on this head.
Conclusion: can merge
- Blocking items
- None from my side on the latest head.
- Suggested non-blocking follow-up
- None from my side on this path.
From the code-review side this looks ready.
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.
Purpose of this pull request
Fix Paimon sink branch handling in save mode and schema evolution.
Previously, Paimon save mode DDL was executed against the main table before the writer switched to the configured branch. This could make
schema_save_mode=RECREATE_SCHEMAdrop/recreate the main table,data_save_mode=DROP_DATAtruncate the main table, or branch auto-create scenarios accidentally create a main table.Schema evolution also used a non-branch Paimon
Identifier, so alter table events were applied to the main table while the writer wrote to the branch.This PR rejects unsupported non-main branch save mode paths before DDL execution and applies schema evolution with a branch-aware
Identifier.Does this PR introduce any user-facing change?
Yes.
For Paimon sink non-main branches, the main table and target branch must already exist.
schema_save_mode=RECREATE_SCHEMAanddata_save_mode=DROP_DATAare rejected for non-main branches to avoid modifying the main table.The Paimon sink documentation is updated with this constraint.
How was this patch tested?
Added
PaimonBranchSaveModeHandlerTestto cover:data_save_mode=DROP_DATAdoes not truncate/drop branch metadataschema_save_mode=RECREATE_SCHEMAdoes not drop/recreate the main tableVerified with:
./mvnw spotless:check -pl seatunnel-connectors-v2/connector-paimon ./mvnw -pl seatunnel-connectors-v2/connector-paimon -Dtest=PaimonBranchSaveModeHandlerTest test ./mvnw spotless:apply -pl seatunnel-connectors-v2/connector-paimon ./mvnw -q -DskipTests verifyCheck list
New License Guide
incompatible-changes.mdto describe the incompatibility caused by this PR.