[FLINK-40647][runtime] Support best-effort schema expansion for existing sink tables during table creation - #4540
haruki-830 wants to merge 9 commits into
Conversation
lvyanquan
left a comment
There was a problem hiding this comment.
Thank you for your contribution. I’ve left a few comments.
|
Could we add an end-to-end test that exercises the full configuration pipeline? The current tests are thorough at the algorithm level ( No test currently verifies that the |
4787aa6 to
647bdbf
Compare
542efd3 to
afd17b8
Compare
From my side, I have tow advice in design side, @haruki-830 @leonardBang , @lvyanquan , WDYT?[Suggestion] Add a check-only mode for pipelines where the target schema is managed externally
[Concern] A transient failure of a supported expansion silently degrades into permanent column loss
|
…ing sink tables during table creation
Rewrite the test following MySqlToPaimonE2eITCase conventions and fix issues that prevented it from running: - Drop the duplicate Container import that broke compilation - Move scan.startup.mode: snapshot into the batch case only, so the streaming case keeps an unbounded source and stays RUNNING - Wait for a terminal state in the batch case - Restore scan.startup.mode: full for the Fluss source - Give the pre-created Paimon table a primary key matching the source - Pass the matching connector jars per SQL client invocation
…xpansion e2e The pre-created Paimon target table used a fixed bucket (=4), which mismatches the CDC Paimon sink's pre-partitioning: PaimonHashFunction builds its routing schema with empty options and never queries the catalog, so it assumes Paimon's default dynamic bucket. Records then get routed to subtasks that do not own the target bucket, leaving the sink partially written. Use 'bucket' = '-1' (dynamic) so the pre-created table matches what the sink itself would create.
…pansion e2e The Fluss distributed path used scan.startup.mode: full, which bootstraps the initial read from a KV snapshot. The tablet server runs with kv.snapshot.interval: 0s (no snapshots), so the source emitted nothing and the sink stayed empty. Switch to earliest, which reads the changelog from the beginning and does not depend on a KV snapshot. The distributed topology and the schema expansion under test are unaffected. Generated-by: Codex
3388404 to
f66753a
Compare
fe85458 to
f2aed1e
Compare
| existing-table.schema-expansion.mode: "EXPAND" | ||
| ``` | ||
|
|
||
| > Note: `existing-table.schema-expansion.enabled` is no longer supported. Use `existing-table.schema-expansion.mode` with one of `OFF`, `CHECK`, `TRY_EXPAND`, `EXPAND` instead; the previous `enabled: true` maps to `TRY_EXPAND`. Quote the mode value to avoid the bare `OFF` scalar being parsed as a YAML boolean. |
There was a problem hiding this comment.
This note is unnecessary as existing-table.schema-expansion.enabled was never exposed to user.
…n.enabled handling The in-PR enabled key was never released, so the migration note in the docs and the dedicated rejection logic in the YAML parser are unnecessary. Unknown options are still rejected by the generic factory validation. Keep only the YAML quoting hint for the new mode option.
What is the purpose of this pull request?
This PR introduces an opt-in best-effort schema expansion capability for existing sink tables during the initial
CreateTableEvent.When the target table already exists and its schema is narrower than the incoming schema, some sinks may ignore input columns that do not exist in the target table, potentially causing silent data loss.
When enabled, the framework attempts conservative schema expansion, including adding missing nullable non-key columns and safely widening non-key column types. Unsupported, unsafe, or failed operations are delegated to the sink's existing handling without introducing new framework-level fail-fast behavior.
Brief change log
existing-table.schema-expansion.enabled, disabled by default.MetadataApplierextension for querying and normalizing the existing target schema.Documentation
JIRA issue
https://issues.apache.org/jira/browse/FLINK-40647