Skip to content

[Fix][Connector-V2][MySQL-CDC] Resolve DDL column names case-insensitively - #13297

Open
SEPURI-SAI-KRISHNA wants to merge 4 commits into
apache:devfrom
SEPURI-SAI-KRISHNA:fix-mysql-cdc-ddl-column-case
Open

SEPURI-SAI-KRISHNA wants to merge 4 commits into
apache:devfrom
SEPURI-SAI-KRISHNA:fix-mysql-cdc-ddl-column-case

Conversation

@SEPURI-SAI-KRISHNA

Copy link
Copy Markdown
Collaborator

Yes, glad to contribute to Apache SeaTunnel.

Purpose of this pull request

Closes #13296.

MySQL column names are case-insensitive, so MySQL accepts DDL that names an existing column in another case than the table defines it, for example AFTER NAME for the column name. MySQL-CDC passed such names on as written (CustomAlterTableParserListener takes them from the statement, and the resolver parses with an empty Debezium Tables), and AlterTableSchemaEventHandler compares names exactly. On dev:

  • ADD COLUMN ... AFTER NAME fails the job with SchemaEvolutionException since [Fix][API] Reject an ADD COLUMN whose AFTER column is missing from the schema #13267 (before it, the column was silently added first);
  • DROP COLUMN Name and MODIFY COLUMN NAME ... are not applied;
  • MODIFY ... AFTER AMOUNT throws NoSuchElementException, and CHANGE COLUMN NAME ... throws IndexOutOfBoundsException;
  • CHANGE COLUMN name NAME ... renames the column to NAME in the schema, while Debezium keeps name, so the change records no longer match it.

#13267 is right to reject an anchor the table does not have. Here the table has it, so the fix gives the event the table's name for it, instead of loosening the handler.

Changes:

  • AbstractSchemaChangeResolver.resolve rewrites the existing columns each parsed event refers to (the dropped, modified or renamed column and the AFTER anchor) through a new resolveColumnName hook, against the source catalog table it already receives. Columns that an earlier part of the same statement adds or renames count for the later parts (ADD x ..., ADD y ... AFTER X). The rewritten event keeps the job id, statement, dialect and changeAfter.
  • The default resolveColumnName keeps the parsed name, so SQL Server, Oracle and the other resolvers are unchanged; in a case-sensitive dialect "Name" and name are different columns.
  • MySqlSchemaChangeResolver overrides it: a name that is not a column is resolved to the column that matches it ignoring case, when exactly one does. A name that matches nothing is kept, so the handler still reports it.
  • Every resolved column keeps the table's name, which is what Debezium's own table model does: after MODIFY COLUMN NOTE ... Debezium's column is still note, and the change records carry that name. MySQL itself renames the column to NOTE here; I first followed MySQL, and the E2E then lost the values of that column, because the rows still arrive as note. A test now compares the names with Debezium's table model.
  • For the same reason, a CHANGE COLUMN whose new name is the old one in another case keeps the old name (a type change in it still applies).
  • Sinks read the column names from the event, so they now also get the table's names (for example the JDBC sink's ALTER TABLE ... AFTER).

Notes for reviewers:

Does this PR introduce any user-facing change?

Yes. With schema-changes.enabled = true, MySQL DDL that names an existing column in another case is applied to that column and the job keeps running. The MySQL-CDC page (EN and ZH) says so in its schema evolution section. No option, default or API changes.

How was this patch tested?

  • MySqlSchemaChangeResolverColumnCaseTest (10 tests) runs the real resolver on a schema change record and applies the result with AlterTableSchemaEventHandler: ADD ... AFTER NAME, DROP COLUMN Name, MODIFY COLUMN NAME VARCHAR(128) (checks the new type), MODIFY ... AFTER AMOUNT, CHANGE COLUMN NAME full_name, CHANGE COLUMN name NAME, an anchor added earlier in the same statement, the names carried by the event, a name that matches nothing, and the names after each of those statements against Debezium's MySqlAntlrDdlParser table model. With the resolver of dev, 9 of the 10 fail (all but the name that matches nothing), as listed above.
  • AbstractSchemaChangeResolverTest#testResolveColumnNamesKeepsParsedNamesByDefault: the base resolver returns the same events.
  • I broke the change on purpose, one mutation at a time, and tests failed each time: the MySQL lookup off (7 of the first 8 fail), no tracking within a statement (1), a case-insensitive default in the base resolver (1), MODIFY renaming the column to the name as written (2, one of them the Debezium comparison), a case-only CHANGE taking the new name (2).
  • connector-cdc-base 144 and connector-cdc-mysql 69 unit tests pass.
  • MysqlCDCWithSchemaChangeIT#testMysqlCdcWithColumnNamedInAnotherCase (new, Zeta): its own source and sink table and job; while the job runs, add column note ... after NAME, modify column NOTE ... after WEIGHT, change column Description details ..., drop column WEIGHT and change column details DETAILS ..., each followed by rows, then an update and a delete. Sink structure (column names compared ignoring case, see above) and rows must match the source. The whole MysqlCDCWithSchemaChangeIT (7 tests) passes locally on Zeta. In the new case the sink ran ADD COLUMN note ... AFTER name, MODIFY COLUMN note ... AFTER weight, CHANGE COLUMN description details ..., DROP COLUMN weight and CHANGE COLUMN details details .... With the MySqlSchemaChangeResolver of dev the job fails on the first statement with SchemaEvolutionException: ... Cannot add column 'note' after 'NAME' and ends FAILED.
  • spotless:check, MarkdownTest, git diff --check.

Check list

  • If any new Jar binary package adding in your PR, please add License Notice according
    New License Guide (no new jar)
  • If necessary, please update the documentation to describe the new feature. https://github.com/apache/seatunnel/tree/dev/docs
  • If necessary, please update incompatible-changes.md to describe the incompatibility caused by this PR. (not needed: no incompatible change)
  • If you are contributing the connector code, please check that the following files are updated: (not a new connector)

…ively

MySQL column names are case-insensitive, so DDL may name an existing
column in another case, for example AFTER NAME for the column name.
MySQL-CDC passed such names on as written, and the schema handler
compares names exactly: ADD COLUMN ... AFTER failed the job (since
apache#13267), DROP COLUMN and MODIFY COLUMN were not applied, and MODIFY or
CHANGE with such a name threw NoSuchElementException or
IndexOutOfBoundsException.

AbstractSchemaChangeResolver now rewrites the columns an event refers to
(dropped, modified or renamed column, AFTER anchor) through a
resolveColumnName hook before the event goes on, tracking columns that
earlier parts of the same statement add or rename. The default keeps the
parsed name, so other CDC connectors are unchanged. MySqlSchemaChangeResolver
resolves a name to the table column that matches it ignoring case, when
exactly one does. Every resolved column keeps the table's
name, as Debezium's own table model does, because the change records
carry those names; that includes a CHANGE COLUMN that renames a column
only by case.

Tests: MySqlSchemaChangeResolverColumnCaseTest (resolver plus schema
handler, 10 cases, one comparing the names with Debezium's table model), a default-keeps-names case in
AbstractSchemaChangeResolverTest, and
MysqlCDCWithSchemaChangeIT#testMysqlCdcWithColumnNamedInAnotherCase.
Docs: MySQL-CDC schema evolution note, EN and ZH.

@DanielLeens DanielLeens left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the careful Apache SeaTunnel regression coverage! I reviewed the complete ten-file diff and followed the DDL event through normalization, schema application and the sink path.

What problem does this PR solve?

User problem: MySQL accepts references such as AFTER NAME when the stored column is name, but the CDC event/schema handler compares exact names. That can fail or ignore a valid schema change.

Fix: Resolve existing-column references to catalog spelling before event completion, with a MySQL-specific case-insensitive lookup and same-statement name tracking.

In one sentence: Apply valid MySQL DDL to the same columns Debezium uses for subsequent rows.

1. Code changes

1.1 Core logic

Before / after: normalizeTableIdentifiers -> completeSchemaChangeEvents becomes normalizeTableIdentifiers -> resolveColumnNames -> completeSchemaChangeEvents in AbstractSchemaChangeResolver.resolve():103-108. The new default hook returns its input; MySQL resolves only unique case-insensitive matches and preserves unknown names. ADD/DROP/MODIFY/CHANGE references and AFTER anchors are rewritten, and added/renamed names are tracked across a compound statement. Case-only renames retain Debezium's existing spelling.

Key findings: Ordinary DDL using exact spelling retains its behavior; differently cased existing names now reach the handler correctly; unknown anchors still fail rather than being silently placed first; default dialect behavior remains exact and is covered.

MySqlIncrementalSource schema-change resolver registration:276
 -> Debezium schema record -> SeaTunnelRowDebeziumDeserializeSchema:135-140
 -> AbstractSchemaChangeResolver.resolve():91
 -> parser -> authoritative table identity -> column-name resolution:291
 -> event completion:170 -> AlterTableColumnsEvent
 -> schema filter -> AlterTableSchemaEventHandler (ADD:104, DROP:149, MODIFY:163, CHANGE:189)
 -> updated CatalogTable + downstream schema event
 -> subsequent rows bind against matching Debezium column names

The default shared hook is dialect-neutral; putting case folding into the common handler would break case-sensitive sources. Moving MySQL rewriting after super.resolve would be too late for metadata completion, so the pre-completion extension point is justified.

1.2 Compatibility

Compatible correction within MySQL's supported schema-change contract. No option/default, event class/serialized field, SPI removal or checkpoint format changes. Other dialects keep the default identity resolver. Existing unsupported parser operations listed in the description remain outside this fix and are not claimed as newly supported.

1.3 Performance and side effects

O(columns x DDL references) lookup and small per-DDL collections, not per-row work. No added RPC, queue, timer, lock, retry or thread. Metadata is copied when rebuilding an event; existing schema-handler/error propagation stays intact. No new resource owner.

1.4 Errors, logging, and findings

No blocking runtime issue found. Unknown names stay unknown, preserving the existing missing-anchor SchemaEvolutionException. Generic parse errors retain existing handling; the patch does not turn those failures into success.

Issue 1 (Medium, non-blocking): seatunnel-connectors-v2/connector-cdc/connector-cdc-mysql/src/test/java/org/apache/seatunnel/connectors/seatunnel/cdc/mysql/source/MySqlSchemaChangeResolverColumnCaseTest.java:58 introduces a regression class without a class-level purpose comment. Please add a short Javadoc explaining the Debezium spelling invariant and the component boundary it covers. Existing method comments and production hook documentation are useful. Raised by others: no.

2. Code quality

2.1 Conventions

The hook and MySQL implementation explain their contracts; event metadata is preserved, including job ID, statement, dialect and changeAfter. ASF headers are present. Issue 1 is documentation of the new test class, not a functional merge blocker.

2.2 Test coverage and stability

Stability: stable for the added component cases and condition-based IT assertions. Unit cases exercise the real parser/resolver/handler with deterministic schemas and compare Debezium's own model. The IT uses its own tables and job ID, waits for incremental consumption and exact schema/data convergence, and retains case-insensitive column-name comparison only where MySQL/Debezium deliberately differ. No new fixed sleep or weakened existing assertion; non-shared test containers are torn down by TestCaseInvocationContextProvider's after-test callback. The discarded asynchronous job Future is less informative on failure, but the data/schema assertions still require the changed behavior. CI failure is discussed below and does not prove this scenario failed.

2.3 Documentation

EN/ZH schema-evolution notes agree and describe existing-column case semantics without changing configuration names.

3. Architecture

3.1 Change location

Best location: yes. MySQL spelling belongs in its resolver; the shared extension point only supplies the correct pre-completion ordering and defaults to identity. Global case-insensitive schema handlers would affect unrelated dialects; duplicating the full base resolve pipeline in MySQL would be a larger maintenance risk.

3.2 Maintainability

The lookup rejects ambiguity and same-statement tracking is local. Tests guard the reason for keeping Debezium spelling rather than blindly copying the latest server case.

3.3 Extensibility

Other dialects may override the hook only when their naming contracts require it; the default contract remains unchanged.

3.4 Upgrade impact

No serialized-state migration. The correction affects future supported DDL events and does not repair historical schemas that already diverged.

4. Findings summary

# Finding Location Severity
1 Document the new regression class boundary seatunnel-connectors-v2/connector-cdc/connector-cdc-mysql/src/test/java/org/apache/seatunnel/connectors/seatunnel/cdc/mysql/source/MySqlSchemaChangeResolverColumnCaseTest.java:58 Medium, non-blocking

5. Merge recommendation

Merge after the required current-head CI passes.

Blocking items: No source blocker found. The failed JDK 17 updated-modules-integration-test-part-5 job failed during Maven Wrapper bootstrap: repeated HTTP 429 from Maven Central, then MavenWrapperMain ClassNotFoundException. It never reached its tests. Please rerun that failed job once repository access recovers, retaining its new URL if it fails again. I checked the latest dev history for mvnw/.mvn since this branch point: no bootstrap change supplies a verified sync-based remedy.

Non-blocking suggestions: Issue 1. Keeping a handle to the asynchronous IT job could also improve failure diagnostics; it is not necessary to change production code for the observed Maven download failure.

No earlier technical review was present in the collected history. Failing setup job. The current Build failure is a separate merge gate; no unrelated dependency patch or branch sync is requested on the strength of HTTP 429.

CI and repository state: Signal pull request update: SUCCESS; Build: FAILURE; Build: failure. GitHub reports BLOCKED / REVIEW_REQUIRED.

Verification: Reviewed all changed files and the referenced call sites at 8b4f3193cf0c6f234e9e03337d1b0b998559d8d9 against merge base c812d79ce156e98b3dc6f77861211b117025cedb. git diff --check passed. I did not build, run tests, or execute SeaTunnel locally.

@SEPURI-SAI-KRISHNA

Copy link
Copy Markdown
Collaborator Author

@DanielLeens Thanks for the review. The class Javadoc is added in f0eaf2ed80. It says that each case runs a DDL record through MySqlSchemaChangeResolver and applies the event with AlterTableSchemaEventHandler, as the source does, and that the schema must keep the column names of Debezium's table model, because the change records after the DDL carry those names and a column the schema names differently gets no value.

The failed part-5 job stopped while downloading the Maven wrapper (HTTP 429) and never reached its tests; the push starts a new build.

@DanielLeens DanielLeens left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the update and for explaining the schema-to-record name invariant. I re-read the complete ten-file diff at f0eaf2e; the requested class Javadoc is now present. Thank you for the contribution to Apache SeaTunnel.

What problem does this PR solve?

User pain: MySQL accepts differently cased references to an existing column, but SeaTunnel could reject or misname the resulting schema event. Fix: resolve referenced names against the evolving table names before completing events, with MySQL-only case-insensitive matching. In one sentence: apply legal DDL references to the column Debezium actually emits. Example: ADD email AFTER NAME targets existing name rather than a missing NAME.

1. Code changes

1.1 Core logic

Before: parsed column names passed directly into completion and schema handlers.
After: normalizeTableIdentifiers -> resolveColumnNames -> completeSchemaChangeEvents.

MySQL schema-change SourceRecord -> AbstractSchemaChangeResolver.resolve (103-107)
 -> parser creates column events -> table identifiers normalized
 -> resolveColumnNames walks events in statement order
 -> MySqlSchemaChangeResolver.resolveColumnName (63): exact match or unique ignore-case match
 -> track added/dropped/renamed names for later clauses
 -> complete event metadata -> source catalog/schema update -> downstream schema event
 -> subsequent record fields use Debezium table-model names

Key findings: normal enabled schema evolution reaches this path; the default hook returns parsed names unchanged, preserving case-sensitive dialects; case-only CHANGE keeps Debezium spelling; newly added names can anchor later clauses. Rebuilt events preserve job, statement, dialect and change-after metadata. Shared placement supplies the necessary pre-completion seam; the actual case rule remains MySQL-owned. A connector-owned whole-event normalizer would be an alternative if that seam is expanded later; no change to case-sensitive callers is needed now.

1.2 Compatibility

Fully compatible for API defaults, configuration, protocols and serialized events. The protected default hook is identity behavior for other dialects. MySQL DDL now follows its existing accepted case semantics. No migration.

1.3 Performance and side effects

Additional name set and event list per DDL; MySQL ignore-case fallback scans column names. It does not add per-row work, persistent cache, network requests, threads or locks. Retry/checkpoint mechanics remain unchanged.

1.4 Errors, logging, and findings

No blocking source issue found. Unresolved names stay parsed so the normal handler can report an error; ambiguous fallback does not silently select a column. The requested class-level contract is present at MySqlSchemaChangeResolverColumnCaseTest.java:45. No non-Daniel technical review exists on this PR to duplicate.

2. Code quality

2.1 Conventions

Core normalization and dialect override explain their purpose and preserve metadata. The class Javadoc now states that tests run a real DDL record through the resolver and schema handler, and why the output must match Debezium.

2.2 Test coverage and stability

Stability rating: stable for the changed assertions. The resolver tests compare actual resulting column order/types with explicit expected values and the independent Debezium table model. The default-hook test checks identity for case-sensitive names. MysqlCDCWithSchemaChangeIT.java:656 waits for incremental readiness and then polls real structure/data after DDL; no new tight clock assertion or fixed sleep. Its shared existing container/streaming-job harness remains a CI integration dependency.

2.3 Documentation

Both MySQL guides describe the same case-insensitive reference behavior. This does not add the separate RENAME COLUMN syntax handler from #13308.

3. Architecture

3.1 Change location

Precise pre-completion normalization, with the database case rule in MySqlSchemaChangeResolver. Moving it after schema completion would be too late for name-dependent metadata lookup.

3.2 Maintainability

Statement-order name tracking avoids resolving later anchors against a stale original column list. Keep future name rules explicitly dialect-owned.

3.3 Extensibility

The default identity hook lets another dialect opt in without imposing MySQL case behavior globally.

3.4 Upgrade impact

No job/checkpoint migration or changed defaults. Historical case-sensitive dialect behavior stays intact.

4. Findings summary

# Finding Location Severity
- No new source blocker found - -

5. Merge recommendation

Merge after current-head CI and effective maintainer review.

Blocking items: No source blocker remains. The new exact-head fork Build is queued and the Apache Build is in progress in this snapshot. The previous Maven Wrapper HTTP 429 belongs to the older run, so let this head finish before diagnosing a new failure.

Non-blocking suggestions: None required.

The requested documentation is complete and the normal schema-event path matches the intended fix. This is one complete rereview of the current head.

CI and repository state: Signal pull request update: SUCCESS; Build: IN_PROGRESS; Build: queued. GitHub reports BLOCKED / REVIEW_REQUIRED.

Verification: Reviewed all changed files and the referenced call sites at f0eaf2ed80099e123ee4eb73e5034f31c897458d against merge base c812d79ce156e98b3dc6f77861211b117025cedb. git diff --check passed. I did not build, run tests, or execute SeaTunnel locally.

@DanielLeens DanielLeens left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The CI fact in my previous review has changed: the exact-head fork Build and Apache Build have both completed successfully on f0eaf2ed80099e123ee4eb73e5034f31c897458d. My previous full review had cleared the source blockers and only CI remained, so I am changing my technical conclusion to approve. Please disregard the earlier pending/queued CI guidance.

Daniel has READ repository permission. This review does not dismiss historical requested changes or replace the final approval/dismissal step by a maintainer with write access; GitHub's effective review gate remains separate. No additional source change or base sync is requested solely because the branch is behind dev.

…lumn-case

# Conflicts:
#	seatunnel-e2e/seatunnel-connector-v2-e2e/connector-cdc-mysql-e2e/src/test/java/org/apache/seatunnel/connectors/seatunnel/cdc/mysql/MysqlCDCWithSchemaChangeIT.java

@DanielLeens DanielLeens left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for completing the regression explanation. I re-reviewed the entire current diff and its DDL-to-row/sink chain. The production behavior and the new purpose comment remain coherent; I found no remaining source blocker.

What problem does this PR solve?

User pain: valid MySQL DDL can refer to column name using another case, while SeaTunnel schema events match exact names. Fix: resolve existing-column references and AFTER anchors to the source catalog spelling, keeping a sequential name view for multi-clause DDL. In one sentence: schema evolution targets the same columns as following Debezium rows. Example: ADD email AFTER NAME finds the existing name column instead of failing its anchor lookup.

1. Code changes

1.1 Core logic

Complete runtime path:

MySQL binlog DDL -> Debezium SourceRecord
 -> SeaTunnelRowDebeziumDeserializeSchema -> MySqlSchemaChangeResolver.resolve
 -> parse events -> normalize table identifier -> resolve existing names against catalog
 -> sequentially track earlier ADD/DROP/CHANGE names -> complete event definitions
 -> AlterTableColumnsEvent with source dialect and original statement
 -> source schema handler applies ordered changes -> subsequent row field lookup
 -> schema-change propagation/barrier -> sink schema handler and later writes

Key findings and correctness:

I re-read all ten changed files and the complete resolver/application path. The generic resolver defaults to preserving names; only MySQL overrides matching, and exact spelling takes priority over a unique case-insensitive match. The pass precedes event completion, so both existing-column lookup and sink event names agree. ADD only resolves its anchor, DROP resolves the old name, MODIFY preserves the Debezium spelling, and CHANGE resolves the old name plus a case-only new spelling. Sequential tracking lets later clauses refer to an earlier addition or rename. Unknown/ambiguous names stay unresolved for the existing handler error instead of being guessed. Event replacements retain job ID, statement, dialect and changeAfter metadata. The new class-level test comment closes the optional item from my earlier round. No source-level blocker was found.

Before:

import org.apache.seatunnel.api.table.catalog.Column;
import org.apache.seatunnel.api.table.catalog.TableIdentifier;
import org.apache.seatunnel.api.table.catalog.TablePath;
import org.apache.seatunnel.api.table.schema.event.AlterColumnCommentEvent;
import org.apache.seatunnel.api.table.schema.event.AlterTableChangeColumnEvent;
import org.apache.seatunnel.api.table.schema.event.AlterTableColumnEvent;
import org.apache.seatunnel.api.table.schema.event.AlterTableColumnsEvent;
import org.apache.seatunnel.api.table.schema.event.AlterTableCommentEvent;
import org.apache.seatunnel.api.table.schema.event.AlterTableEvent;
import org.apache.seatunnel.api.table.schema.event.AlterTableModifyColumnEvent;
import org.apache.seatunnel.api.table.schema.event.SchemaChangeEvent;

After:

import org.apache.seatunnel.api.table.catalog.Column;
import org.apache.seatunnel.api.table.catalog.TableIdentifier;
import org.apache.seatunnel.api.table.catalog.TablePath;
import org.apache.seatunnel.api.table.catalog.TableSchema;
import org.apache.seatunnel.api.table.schema.event.AlterColumnCommentEvent;
import org.apache.seatunnel.api.table.schema.event.AlterTableAddColumnEvent;
import org.apache.seatunnel.api.table.schema.event.AlterTableChangeColumnEvent;
import org.apache.seatunnel.api.table.schema.event.AlterTableColumnEvent;
import org.apache.seatunnel.api.table.schema.event.AlterTableColumnsEvent;
import org.apache.seatunnel.api.table.schema.event.AlterTableCommentEvent;
import org.apache.seatunnel.api.table.schema.event.AlterTableDropColumnEvent;
import org.apache.seatunnel.api.table.schema.event.AlterTableEvent;
import org.apache.seatunnel.api.table.schema.event.AlterTableModifyColumnEvent;
import org.apache.seatunnel.api.table.schema.event.SchemaChangeEvent;

1.2 Compatibility

Fully compatible for existing options, public source/sink APIs, event/row protocols and checkpoint state. MySQL schema evolution now accepts valid alternate-case references and preserves Debezium spelling for following rows; other dialects retain exact-name behavior through the identity hook.

1.3 Performance and side effects

A transient set of column names and replacement events is allocated only per DDL, with linear case-insensitive scans when exact lookup misses. There is no new per-row scan, network call, retained global buffer, lock, retry or resource owner.

1.4 Errors, logging, and findings

No new source-level blocker found. Exceptions must still reach the existing job failure path; this review does not substitute for current-head CI.

No independent reviewer technical objection or maintainer merge recommendation was present in the collected current discussion. My previous approval was on an older head, so it is not treated as a completed review of this revised version.

2. Code quality

2.1 Conventions

Reviewed all changed files for license, imports, naming, core-method and state-field comments. No additional convention blocker found.

2.2 Test coverage and stability

Stability rating: Stable. The new resolver tests apply real parsed events with AlterTableSchemaEventHandler and independently compare the resulting names against Debezium's own table model. They cover add/drop/modify/change, case-only rename, multi-clause anchors, unknown anchors and a default case-sensitive resolver. The existing MySQL CDC IT adds a dedicated source/sink fixture, waits for incremental-read state, performs DDL with subsequent inserts/updates/deletes, and conditionally polls actual schema/data equality. No fixed sleep or new resource/port dependency is added by this change; asynchronous submission and container cleanup follow the existing suite lifecycle. Stable based on the changed assertions; actual current-head whole-CI success has not been established.

2.3 Documentation

EN and ZH consistently explain MySQL existing-column case insensitivity with the same AFTER example. Other dialects and existing option defaults are unchanged. No migration or checkpoint-format change is needed.

3. Architecture

3.1 Change location

Normalize dialect-specific names before shared schema application; the default identity hook preserves other connectors. Do not make generic Column lookup case-insensitive or alter sink-wide matching rules.

3.2 Maintainability

Keep the behavior, lifecycle ownership, and failure contract together. Normalize dialect-specific names before shared schema application; the default identity hook preserves other connectors. Do not make generic Column lookup case-insensitive or alter sink-wide matching rules.

3.3 Extensibility

Prefer the existing component boundary and tests over unrelated shared abstractions.

3.4 Upgrade impact

Fully compatible for existing options, public source/sink APIs, event/row protocols and checkpoint state. MySQL schema evolution now accepts valid alternate-case references and preserves Debezium spelling for following rows; other dialects retain exact-name behavior through the identity hook.

4. Findings summary

# Finding Location Severity
- No new source blocker found - -

5. Merge recommendation

Can merge once the recorded CI and repository gates are satisfied

Blocking items: No source blocker. Current-head CI and write-capable maintainer review remain independent requirements.

Non-blocking suggestions: None beyond the validation limits above.

Overall: the reviewed source path is coherent; no runtime acceptance is claimed beyond the actual CI result. Daniel has READ permission, so this COMMENT cannot dismiss historical requested changes or satisfy a write-capable maintainer approval gate.

CI and repository state: Signal pull request update: SUCCESS; Build: FAILURE; Build: failure. GitHub reports BLOCKED / REVIEW_REQUIRED.

Verification: Reviewed all changed files and the referenced call sites at e8806f34112adf77dbe6680afcb763f43efa248d against merge base e2597998a991f30fd7c13a634cdd07c7a0a5db44. git diff --check passed. I did not build, run tests, or execute SeaTunnel locally.

Review time: 2026-11-20T07:00:28.786142-05:00

Local evidence: git fetch obtained head e8806f34112adf77dbe6680afcb763f43efa248d; git merge-base returned e2597998a991f30fd7c13a634cdd07c7a0a5db44; git diff --stat reports 10 files changed, 658 insertions(+). git show and source searches were used for the entry points above. No local build, unit test, E2E, Docker run or service startup was executed.

Current CI detail: The exact-head fork Build is failed. Updated-modules partition 8 JDK 11 (job 136105242897) and Redis JDK 17 (136105243102) stop before tests with MavenWrapperMain missing after wrapper download failure. The downloaded unit-test JDK 17 log (136105242215) ends during dependency retrieval without a terminal failure diagnostic, so its root cause is not established here. The wrapper is unchanged in latest dev; a sync is not a demonstrated cure. Please preserve that unit-lane terminal log and obtain completed results for the failed lanes, without adding unrelated Redis/wrapper changes to this schema fix.

@DanielLeens DanielLeens left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for following this through! The CI fact in my previous review has changed on this unchanged head: the exact-head Build is successful and Apache now reports a successful Build too. I checked the final job manifest: no failed, cancelled or incomplete jobs remain. My previous complete review had no unresolved source blocker; the remaining technical blocker was CI/check adoption. That CI-only blocker is now cleared, so I am changing my technical review to approve.

Conclusion: Can merge from Daniel's technical perspective once the effective repository review gate is satisfied.

Blocking source items: None from my existing complete review.

Non-blocking suggestions: Those already recorded remain optional. This is a CI/discussion follow-up, not another full source review. Daniel's READ permission does not provide write-level approval/dismissal controls or prove that historical requested changes have disappeared. A write-capable maintainer must handle the remaining effective gate.

Checked unchanged head e8806f34112adf77dbe6680afcb763f43efa248d against dev: compare diverged, ahead 3 / behind 4. This drift is recorded independently; it does not by itself request synchronization. This is a discussion/CI follow-up, not another full source review. No local build, test or runtime execution was performed. Daniel has READ repository permission; effective maintainer approval/dismissal remains a separate repository gate. Checked 2026-11-21T11:49:26.872558+00:00.

…lumn-case

# Conflicts:
#	seatunnel-connectors-v2/connector-cdc/connector-cdc-base/src/main/java/org/apache/seatunnel/connectors/cdc/base/schema/AbstractSchemaChangeResolver.java
#	seatunnel-connectors-v2/connector-cdc/connector-cdc-mysql/src/main/java/org/apache/seatunnel/connectors/seatunnel/cdc/mysql/source/MySqlSchemaChangeResolver.java

@DanielLeens DanielLeens left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for adding the test contract explanation! I re-reviewed the complete current head, including the shared resolver, MySQL override, deterministic parser tests and the existing CDC E2E path. The previous comment requirement is closed, and I found no new source blocker.

What problem does this PR solve?

User pain: valid MySQL DDL can reference a column with different capitalization, while exact-name schema application fails or loses alignment. Fix: normalize existing column references and AFTER anchors to the captured schema using a MySQL-only case-insensitive hook, tracking earlier clauses. In one sentence: AFTER NAME finds existing name without changing case-sensitive dialect behavior. Example: adding email AFTER NAME now preserves id,name,email,amount rather than failing the source schema update.

1. Code changes

1.1 Core logic

Complete runtime path:

MySQL binlog schema SourceRecord -> incremental stream fetcher -> SeaTunnelRowDebeziumDeserializeSchema.deserializeSchemaChangeRecord :140
 -> MySqlSchemaChangeResolver -> AbstractSchemaChangeResolver.resolve :91
 -> parse DDL -> normalize identifiers -> resolveColumnNames :106 -> complete event metadata -> filter events
 -> AlterTableSchemaEventHandler applies each column event -> update captured CatalogTable -> emit schema event downstream
 -> subsequent Debezium row fields map to the same captured column names -> sink schema evolution/write
Non-MySQL dialect -> default resolveColumnName returns parsed name unchanged

Key findings and correctness:

  • Read the complete 10-file diff and its deserializer/schema-handler entry points. This is a normal schema-evolution path when MySQL DDL uses another case; ordinary row processing without schema DDL is unchanged.
  • Resolve exact matches first, otherwise exactly one equalsIgnoreCase match; unknown/ambiguous references stay parsed for the existing handler. No global lowercasing of new columns or table names is added.
  • Ordered name tracking handles columns added, dropped and renamed earlier in one statement. CHANGE only normalizes a case-only rename against its own old name, matching Debezium's table-model convention and subsequent row field names. Reconstructed events retain metadata.
  • The default base hook is identity: the existing case-sensitive dialect test preserves event identity and parsed names. Shared control flow is touched, but MySQL supplies the actual semantic difference.
  • The previously requested test-class contract comment is now present. This is a precise dialect correction; no new source blocker found.

Before:

import org.apache.seatunnel.api.table.catalog.Column;
import org.apache.seatunnel.api.table.catalog.TableIdentifier;
import org.apache.seatunnel.api.table.catalog.TablePath;
import org.apache.seatunnel.api.table.schema.event.AlterColumnCommentEvent;
import org.apache.seatunnel.api.table.schema.event.AlterTableChangeColumnEvent;
import org.apache.seatunnel.api.table.schema.event.AlterTableColumnEvent;
import org.apache.seatunnel.api.table.schema.event.AlterTableColumnsEvent;
import org.apache.seatunnel.api.table.schema.event.AlterTableCommentEvent;
import org.apache.seatunnel.api.table.schema.event.AlterTableEvent;
import org.apache.seatunnel.api.table.schema.event.AlterTableModifyColumnEvent;
import org.apache.seatunnel.api.table.schema.event.SchemaChangeEvent;

After:

import org.apache.seatunnel.api.table.catalog.Column;
import org.apache.seatunnel.api.table.catalog.TableIdentifier;
import org.apache.seatunnel.api.table.catalog.TablePath;
import org.apache.seatunnel.api.table.catalog.TableSchema;
import org.apache.seatunnel.api.table.schema.event.AlterColumnCommentEvent;
import org.apache.seatunnel.api.table.schema.event.AlterTableAddColumnEvent;
import org.apache.seatunnel.api.table.schema.event.AlterTableChangeColumnEvent;
import org.apache.seatunnel.api.table.schema.event.AlterTableColumnEvent;
import org.apache.seatunnel.api.table.schema.event.AlterTableColumnsEvent;
import org.apache.seatunnel.api.table.schema.event.AlterTableCommentEvent;
import org.apache.seatunnel.api.table.schema.event.AlterTableDropColumnEvent;
import org.apache.seatunnel.api.table.schema.event.AlterTableEvent;
import org.apache.seatunnel.api.table.schema.event.AlterTableModifyColumnEvent;
import org.apache.seatunnel.api.table.schema.event.SchemaChangeEvent;

1.2 Compatibility

Fully compatible for supported APIs/config/defaults/protocol/state formats. MySQL DDL existing-name matching now follows its case-insensitive semantics while preserving captured field spelling; non-MySQL default resolution stays case-sensitive. Existing names and schema event wire types remain unchanged. No migration is required.

1.3 Performance and side effects

Normalization is per DDL event, using a bounded copy of table column names and linear matching per reference; it is not a per-row scan. No additional network request, background thread, lock or retry. Events are local copies and no state serialization format changes. Existing deserializer exception/log handling remains unchanged.

1.4 Errors, logging, and findings

No new source-level blocker found. Exceptions must still reach the existing job failure path; this review does not substitute for current-head CI.

No independent non-author technical finding or maintainer merge recommendation was present in collected reviews/inline comments. The author's Javadoc explanation matches the new class contract and actual test parser/handler path.

2. Code quality

2.1 Conventions

Reviewed all changed files for license, imports, naming, core-method and state-field comments. No additional convention blocker found.

2.2 Test coverage and stability

Stability rating: Stable. Stable: MySqlSchemaChangeResolverColumnCaseTest.java:67-199 deterministically parses/applies ADD/DROP/MODIFY/CHANGE and multiple clauses, comparing actual Debezium model names. AbstractSchemaChangeResolverTest.java:370-406 verifies default case-sensitive behavior. MysqlCDCWithSchemaChangeIT.java:908-964 awaits initial data, incremental-reader evidence, normalized final structure and exact ordered data; SQL fixtures include rows after every DDL, UPDATE and DELETE. No fixed sleep assertion was added. Its async job future is not joined; failures surface through bounded state/data assertions, with weaker diagnostics. Non-shared test containers are torn down by TestCaseInvocationContextProvider.java:118-125. Current-head CI remains separately reported; no tests ran locally.

2.3 Documentation

Both MySQL-CDC pages describe the same case-insensitive existing-column/AFTER behavior. No new option, connector identity, dependency or packaging resource is introduced.

3. Architecture

3.1 Change location

Keep dialect policy in the MySQL override and use an identity default for other resolvers. The existing event application boundary remains the single schema owner; no connector-specific engine special case is needed.

3.2 Maintainability

Keep the behavior, lifecycle ownership, and failure contract together. Keep dialect policy in the MySQL override and use an identity default for other resolvers. The existing event application boundary remains the single schema owner; no connector-specific engine special case is needed.

3.3 Extensibility

Prefer the existing component boundary and tests over unrelated shared abstractions.

3.4 Upgrade impact

Fully compatible for supported APIs/config/defaults/protocol/state formats. MySQL DDL existing-name matching now follows its case-insensitive semantics while preserving captured field spelling; non-MySQL default resolution stays case-sensitive. Existing names and schema event wire types remain unchanged. No migration is required.

4. Findings summary

Completeness check: All changed files and affected entry/failure paths were reviewed; configuration/serialization compatibility, test failure capability and stability, documentation/examples, change ownership, and current CI/conflict/review gates are covered above. No unreviewed source scope is claimed complete.

# Finding Location Severity
- No new source blocker found - -

5. Merge recommendation

Can merge once the recorded CI and repository gates are satisfied

Blocking items: No source blocker. Current-head CI and write-capable maintainer review remain independent requirements.

Non-blocking suggestions: None beyond the validation limits above.

Overall: the reviewed source path is coherent; no runtime acceptance is claimed beyond the actual CI result. Daniel has READ permission, so this COMMENT cannot dismiss historical requested changes or satisfy a write-capable maintainer approval gate.

CI and repository state: Signal pull request update: SUCCESS; Build: IN_PROGRESS; Build: queued. GitHub reports BLOCKED / REVIEW_REQUIRED.

Verification: Reviewed all changed files and the referenced call sites at 17968289ff61bac5a273bbaa2dea87ad7cde48c3 against merge base 60e039a810844323172d4048f721bc88146e9a83. git diff --check passed. I did not build, run tests, or execute SeaTunnel locally.

Review time: 2026-11-26T07:37:14.645576-05:00

Local evidence: git fetch obtained head 17968289ff61bac5a273bbaa2dea87ad7cde48c3; git merge-base returned 60e039a810844323172d4048f721bc88146e9a83; git diff --stat reports 10 files changed, 657 insertions(+). git show and source searches were used for the entry points above. No local build, unit test, E2E, Docker run or service startup was executed.

@DanielLeens

Copy link
Copy Markdown
Contributor

The CI fact cited previously has changed: the exact-head fork Build is completed with FAILURE. Two failures need separate handling:

  • Unit-test/JDK11 Windows job 139824278902: MongodbSinkOptionDefaultsTest.explicitRetryIntervalIsStillApplied observes 49 ms against a required 50 ms.
  • MySQL CDC/JDK17 job 139824279879: MysqlCDCWithFlinkSchemaChangeIT.testSchemaEvolutionRecoversAfterTaskManagerFailureBeforeNextCheckpoint times out after five minutes with expected iterable length 10 versus actual 9. This is schema/data reconciliation evidence, not a dependency-download error.

Neither affected test has a later fix in the inspected current-dev history. The CDC failure is in the same schema-evolution domain as this PR, so it must not be dismissed as unrelated merely because the test file is unchanged. Please retain the actual missing schema/row comparison and rerun the affected lane, investigating the changed resolver mapping if it repeats. The Windows timing failure can be retried independently. No blind synchronization or unrelated dependency change is prescribed; the previous source review remains distinct from incomplete runtime acceptance.

Exact-head Build, head 17968289ff61bac5a273bbaa2dea87ad7cde48c3. Compare diverged, ahead 4 / behind 13. No local build/test/runtime execution was performed. Daniel has READ permission; effective maintainer approval/dismissal remains separate.

Current snapshot (2026-11-27T03:06:59.726793+00:00): Signal pull request update: SUCCESS; Build: FAILURE; merge state BLOCKED; review decision REVIEW_REQUIRED.

@SEPURI-SAI-KRISHNA

Copy link
Copy Markdown
Collaborator Author

Thanks @DanielLeens. I checked both failures in the job logs.

  1. Windows, MongodbSinkOptionDefaultsTest.explicitRetryIntervalIsStillApplied (49 ms for 50 ms): this is the timer precision flake that [Test][Connector-V2][MongoDB] Allow for timer precision in the retry back-off test #13450 fixes. This PR does not touch MongoDB.

  2. MysqlCDCWithFlinkSchemaChangeIT line 245 is the data check after the TaskManager stop. The schema check just before it passed. The rows are compared ordered by id, and JUnit 5.9.0 reports "iterable lengths differ" only when every shared position is equal. I checked this locally: dropping row 105 instead gives "contents differ at index [4]". So the sink held the 9 seed rows 101 to 109, equal in every column including recovery_column. The missing row is 190, inserted right after ADD COLUMN recovery_column and before the stop.

The resolver mapping in this PR does not change that statement. It has no AFTER and names no existing column, so resolveColumnNames gets a null anchor and returns the parsed event unchanged. The DROP COLUMN runs only after line 245.

The same assertion failed with the same 10 vs 9 on #13393 at b2408e367e, on JDK 11 (job) and JDK 17 (job). That head merged the same dev (60e039a810) as this one and changes only Transform-V2 code, its docs and JDBC E2E files, no CDC code. I have not found the cause yet.

I have rerun the failed jobs on this head. If the CDC lane fails again here, I will dig into it on this PR. Otherwise I will open a separate issue with the logs.

@DanielLeens

Copy link
Copy Markdown
Contributor

Thanks for distinguishing the old MongoDB precision flake from the schema-recovery observation. I checked the latest exact-head rerun: Build 45958921001 is still queued in its run snapshot, but its changes job already failed while fetching the Maven wrapper (HTTP 429, then MavenWrapperMain missing), before tests. That does not retest the missing row. #13450 and the wrapper fallback #13466 are both still open; the latest dev wrapper/schema-recovery fixture is unchanged, so syncing is not a verified cure today. Let the existing run settle without starting a duplicate; when artifact access recovers and no successor run is active, rerun the failed bootstrap lane. Preserve the missing-row logs for separate focused diagnosis if it recurs. No unrelated resolver/dependency patch is indicated by this setup failure.

This is a discussion/gate follow-up on unchanged head 17968289ff61bac5a273bbaa2dea87ad7cde48c3, not a new full source review. Base dev compare: diverged, ahead 4 / behind 15. Branch drift alone is not a request to sync. No local build/test/runtime execution was performed. Daniel has READ permission; any required write-capable maintainer approval or historical-review dismissal remains separate.

@DanielLeens DanielLeens left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The rerun fact in my previous reply has changed: Build 45958921001 is now completed/failure, rather than queued. Its changes/bootstrap job still failed on Maven wrapper HTTP 429 before the schema-recovery case ran. This result does not retest the missing-row observation. #13466/#13450 remain open and no landed upstream cure is established; sync alone is not a verified fix. Once artifact access recovers and no successor is active, rerun the failed bootstrap lane and retain any later missing-row evidence for focused diagnosis.

5. Merge recommendation

Conclusion: Merge after fixes / remaining repository gates.

Blocking items: No remaining source blocker from Daniel. The current CI/repository gate described above still needs attention.

Non-blocking suggestions: Those from the existing complete review are unchanged; this follow-up adds no source finding. No alternative implementation or unrelated module/dependency patch is requested.

Unchanged head 17968289ff61bac5a273bbaa2dea87ad7cde48c3; base dev compare diverged, ahead 4 / behind 15. This drift is recorded separately and alone does not request synchronization. This is a CI/gate correction, not another full source review; no local build/test/runtime execution was performed. Daniel has READ permission, so historical requested-changes controls and an effective write-level approval/dismissal remain maintainer actions. Checked 2026-11-27T10:23:37.834051+00:00.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug][Connector-V2][MySQL-CDC] Schema evolution fails when DDL names a column in another case

2 participants