You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@seatunnel.apache.org by "zhangshenghang (via GitHub)" <gi...@apache.org> on 2026/04/16 14:35:39 UTC

[PR] [Fix][Connector-V2][Postgres] Add schema evolution support [seatunnel]

zhangshenghang opened a new pull request, #10779:
URL: https://github.com/apache/seatunnel/pull/10779

   ### Purpose of this pull request
   Add schema evolution support for PostgreSQL CDC source, including add/drop/rename/modify column DDL handling, E2E coverage, and PostgreSQL CDC documentation updates.
   
   ### Does this PR introduce _any_ user-facing change?
   Yes. When `schema-changes.enabled = true`, PostgreSQL CDC source can now propagate supported schema evolution events to the sink.
   
   ### How was this patch tested?
   - `./mvnw spotless:apply`
   - `./mvnw -pl seatunnel-connectors-v2/connector-cdc/connector-cdc-postgres -Dtest=PostgresAlterTableParserTest,PostgresSchemaChangeResolverTest -DfailIfNoTests=false -Dspotless.check.skip=true test`
   - `./mvnw -pl seatunnel-connectors-v2/connector-cdc/connector-cdc-base -Dtest=SourceRecordUtilsTest -DfailIfNoTests=false -Dspotless.check.skip=true test` (blocked by existing base-module compile errors unrelated to this change)
   - `./mvnw -pl seatunnel-e2e/seatunnel-connector-v2-e2e/connector-cdc-postgres-e2e -DskipUT -DskipIT=false -Dtest=PostgresCDCIT#testPostgresCdcWithSchemaEvolution -Dspotless.check.skip=true verify` (blocked by missing Docker environment in the local machine)
   
   ### Check list
   - [ ] 新增 Jar 包需按 New License Guide 添加 License
   - [x] 必要时更新文档 (docs/en + docs/zh)
   - [ ] 必要时更新 incompatible-changes.md
   - [x] 连接器代码需更新: plugin-mapping.properties, seatunnel-dist pom, CI label, E2E, plugin_config


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@seatunnel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [Improve][Connector-V2][PostgreSQL-CDC] Prepare schema evolution parsing [seatunnel]

Posted by "DanielLeens (via GitHub)" <gi...@apache.org>.
DanielLeens commented on PR #10779:
URL: https://github.com/apache/seatunnel/pull/10779#issuecomment-5141521569

   Thanks @dybyte for raising this. I agree this is the right question to answer before treating the parser path as production-ready.
   
   From Daniel's side, the current head still needs a clear explanation of where the PostgreSQL DDL string consumed by `PostgresSchemaChangeResolver` comes from in the real pgoutput/Debezium runtime path. If pgoutput only provides relation updates rather than the original DDL, then the PR should either connect this parser to a real upstream input path or narrow/document the scope so we do not merge unused complexity. I would wait for that clarification or an updated commit before another full re-review.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@seatunnel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [Improve][Connector-V2][PostgreSQL-CDC] Prepare schema evolution parsing [seatunnel]

Posted by "DanielLeens (via GitHub)" <gi...@apache.org>.
DanielLeens commented on PR #10779:
URL: https://github.com/apache/seatunnel/pull/10779#issuecomment-5165359302

   Thanks for clarifying that intention.
   
   In that case, I would still avoid merging the parser-only path first on the current head. The blocker I raised earlier remains the same: this PR still needs to show the real pgoutput/Debezium runtime input path that feeds `PostgresSchemaChangeResolver`, or otherwise narrow the scope so we do not merge parsing complexity that is not yet wired into the actual PostgreSQL CDC execution path.
   
   Once that is reflected in code, I am happy to re-review the updated head.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@seatunnel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [Improve][Connector-V2][PostgreSQL-CDC] Prepare schema evolution parsing [seatunnel]

Posted by "DanielLeens (via GitHub)" <gi...@apache.org>.
DanielLeens commented on PR #10779:
URL: https://github.com/apache/seatunnel/pull/10779#issuecomment-5125131043

   CI gate update: the `Build` check that was queued in my previous note has now completed successfully on the current head. I do not see a new Daniel-side source blocker; the remaining step is the normal repository review/merge gate. Because my review controls here may be read-only, a write-capable maintainer may still need to provide the final approval or dismissal in GitHub’s review summary. Thanks again for keeping this PR current.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@seatunnel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [Improve][Connector-V2][PostgreSQL-CDC] Prepare schema evolution parsing [seatunnel]

Posted by "zhangshenghang (via GitHub)" <gi...@apache.org>.
zhangshenghang commented on PR #10779:
URL: https://github.com/apache/seatunnel/pull/10779#issuecomment-5161318317

   @dybyte  Can you continue to optimize it after this PR is merged?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@seatunnel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [Improve][Connector-V2][PostgreSQL-CDC] Prepare schema evolution parsing [seatunnel]

Posted by "dybyte (via GitHub)" <gi...@apache.org>.
dybyte commented on PR #10779:
URL: https://github.com/apache/seatunnel/pull/10779#issuecomment-5162374163

   > Thanks @dybyte and @DanielLeens for pointing this out.
   > 
   > I agree with the concern. With the current PostgreSQL `pgoutput` + Debezium 1.9 baseline, this PR should not assume that the original PostgreSQL DDL statement is available from the production WAL path. `pgoutput` exposes relation metadata updates rather than the raw DDL statement, so a real production schema-evolution implementation would need a different input path, most likely schema diffing from old/new table metadata, before this resolver can be wired into the runtime.
   > 
   > Based on that, I have narrowed the PR to parser/resolver preparation only:
   > 
   > * The PR title is now `Prepare schema evolution parsing`.
   > * `schema-changes.enabled` is not exposed for PostgreSQL CDC.
   > * `PostgresSourceConfigFactory` still sets `include.schema.changes=false`.
   > * `PostgresIncrementalSource` does not wire `PostgresSchemaChangeResolver` into the row deserializer.
   > * `SourceRecordUtils` still does not include PostgreSQL in the shared schema-change event key list.
   > * The Debezium JSON schema-change E2E remains disabled for the Debezium PostgreSQL 1.9 limitation.
   > 
   > So there is currently no production path claiming to consume a DDL string from `pgoutput`. The added parser/resolver code is meant as groundwork for a later PR that supplies a real PostgreSQL schema-change input, for example by comparing relation/table metadata and then mapping that into SeaTunnel schema-change events. I will keep this PR scoped to that preparatory boundary and avoid advertising it as supported PostgreSQL CDC schema evolution.
   > 
   > Also, the latest `Build` is green now.
   
   Thanks for clarifying that the current production path does not provide the original PostgreSQL DDL and that a metadata-diff-based approach would likely be required.
   
   However, I am still unclear about how the parser introduced in this PR would be used in that design. If schema changes are inferred by comparing the previous and current Debezium `Table` metadata, the implementation would appear to produce SeaTunnel schema-change events directly without parsing a DDL string.
   
   Could you clarify the concrete future runtime path that is expected to invoke `PostgresAlterTableParser`? Otherwise, I am concerned that this PR may add a substantial parser implementation that the planned production solution will not use.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@seatunnel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [Improve][Connector-V2][PostgreSQL-CDC] Prepare schema evolution parsing [seatunnel]

Posted by "dybyte (via GitHub)" <gi...@apache.org>.
dybyte commented on PR #10779:
URL: https://github.com/apache/seatunnel/pull/10779#issuecomment-5162376221

   > @dybyte Can you continue to optimize it after this PR is merged?
   
   Of course! I’d be happy to continue working on the actual PostgreSQL CDC schema evolution after this PR is merged.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@seatunnel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [Feature][Connector-V2][PostgreSQL-CDC] Support schema evolution [seatunnel]

Posted by "DanielLeens (via GitHub)" <gi...@apache.org>.
DanielLeens commented on PR #10779:
URL: https://github.com/apache/seatunnel/pull/10779#issuecomment-4518061616

   Thanks for the update. I pulled the latest head `c6ba752d51240a0180863c4f1a956920a78f4047` locally as `seatunnel-review-10779`, reviewed the full diff against `apache/dev`, and retraced the real PostgreSQL CDC schema-change runtime chain.
   
   # What this PR fixes
   - User pain: when PostgreSQL CDC sees DDL such as add/drop/rename/type-change, users want SeaTunnel to forward those schema changes downstream instead of handling DML only.
   - Fix approach: add a PostgreSQL-specific DDL parser, a schema-change resolver, a `schema-changes.enabled` option, and matching tests.
   - In one sentence: this PR is trying to wire PostgreSQL CDC into SeaTunnel's schema-evolution pipeline.
   
   # Runtime path I checked
   ```text
   User enables schema changes
     -> PostgresSourceConfigFactory.create()
         -> sets include.schema.changes in Debezium properties
   
   Debezium deserialization path
     -> PostgresIncrementalSource.createDebeziumDeserializationSchema()
         -> SeaTunnelRowDebeziumDeserializeSchema
             -> setSchemaChangeResolver(new PostgresSchemaChangeResolver(...))
             -> this path is only hit if Debezium actually emits PostgreSQL DDL schema-change records
   
   Current repo baseline
     -> connector-cdc/pom.xml
         -> debezium.version = 1.9.8.Final
     -> PostgresCDCIT.testPostgresCdcWithSchemaEvolution()
         -> @Disabled("Debezium PostgreSQL 1.9 cannot emit DDL schema change events to consumers.")
   ```
   
   # Code review
   ## 1. Core logic
   The parser / resolver work itself is reasonable. I can see the intended chain from `include.schema.changes=true` in `PostgresSourceConfigFactory`, through `PostgresIncrementalSource.createDebeziumDeserializationSchema()`, into `PostgresSchemaChangeResolver`.
   
   The blocker is one level above that code: on the current repository baseline, the required PostgreSQL DDL schema-change events do not actually reach the consumer side. The latest head itself acknowledges this by globally disabling the schema-evolution E2E with `@Disabled("Debezium PostgreSQL 1.9 cannot emit DDL schema change events to consumers.")`, while the project still pins `debezium.version = 1.9.8.Final`.
   
   So the current implementation looks much closer to preparatory infrastructure than to a feature that is actually available to users today.
   
   ## 2. Compatibility
   Default behavior is still compatible because `schema-changes.enabled` remains `false` by default. The risky part is the user-facing contract: once someone enables the flag based on the current docs, they are being promised a capability that the current dependency baseline does not actually deliver.
   
   ## 3. Performance / side effects
   The parser/resolver overhead is fine. The real side effect is contract drift: users can be told a feature exists even though the runtime path is still unreachable.
   
   ## 4. Error handling / logging
   Issue 1: the current repository baseline does not provide a reachable PostgreSQL schema-change user path, but the docs and option contract already advertise it as supported
   - Location: `seatunnel-connectors-v2/connector-cdc/pom.xml:44`; `connector-cdc-postgres/.../PostgresIncrementalSource.java:111-118`; `seatunnel-e2e/.../PostgresCDCIT.java:746-753`; `docs/en/connectors/source/PostgreSQL-CDC.md:104-119`
   - Why this is a problem: the resolver path only matters if Debezium emits PostgreSQL DDL schema-change records to consumers. The latest head explicitly disables the only E2E for that path because Debezium PostgreSQL 1.9 cannot do that, and the repo is still pinned to `1.9.8.Final`.
   - Risk: users enable `schema-changes.enabled` and expect PostgreSQL CDC schema evolution to work, but the actual event source is not there on the current baseline.
   - Best fix: either upgrade to a Debezium baseline that really exposes those PostgreSQL DDL schema-change events and re-enable the E2E, or narrow the user-facing scope/docs so this lands only as internal preparatory code instead of an advertised feature.
   - Severity: High
   - Already raised by others: No
   
   # Testing coverage and stability
   The new unit tests around the parser and resolver are useful and structurally stable. The problem is coverage of the real user path, not flaky assertions: the key E2E is globally disabled, so CI does not currently prove that the advertised capability works.
   
   # Merge conclusion
   ### Conclusion: can merge after fixes
   
   1. Blocking items
   - Issue 1: do not ship this as a supported PostgreSQL CDC schema-evolution feature until the Debezium baseline and the E2E validation path are both real.
   
   2. Suggested follow-up items
   - None beyond the blocker above; that one is the key merge gate.
   
   Overall, I like the direction of the code, but the feature contract currently gets ahead of what the pinned Debezium baseline can actually deliver. Happy to re-review once that gap is closed.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@seatunnel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [Feature][Connector-V2][PostgreSQL-CDC] Support schema evolution [seatunnel]

Posted by "DanielLeens (via GitHub)" <gi...@apache.org>.
DanielLeens commented on PR #10779:
URL: https://github.com/apache/seatunnel/pull/10779#issuecomment-4525120828

   Thanks for the update. I re-reviewed the latest head `c6ba752d51240a0180863c4f1a956920a78f4047` locally against `apache/dev`, and I retraced the PostgreSQL CDC schema-change runtime path again from the consumer side. I did not run Maven locally in this pass; this is a source-level review only.
   
   # What this PR fixes
   - User pain  
     When PostgreSQL CDC sees DDL such as add/drop/rename/type-change, users want SeaTunnel to forward those schema changes downstream instead of handling only DML.
   - Fix approach  
     This PR adds a PostgreSQL-specific parser / resolver chain, `schema-changes.enabled`, tests, docs, and E2E resources.
   - One sentence  
     The parser/resolver code direction is still good, but on the current Debezium 1.9.8.Final baseline the real PostgreSQL DDL user path is still not reachable, and the latest commit makes that even more explicit by disabling the schema-evolution E2E.
   
   # Runtime path I rechecked
   ```text
   User enables schema changes
     -> Postgres source config
         -> include.schema.changes passed to Debezium
   
   Debezium consumer path
     -> if PostgreSQL DDL schema-change SourceRecord is emitted
         -> SeaTunnelRowDebeziumDeserializeSchema
             -> PostgresSchemaChangeResolver
                 -> PostgresAlterTableParser
                 -> AlterTable*Event
         -> downstream schema-evolution sink can consume it
   
   Current repository baseline
     -> connector-cdc/pom.xml:44
         -> debezium.version = 1.9.8.Final
     -> PostgresCDCIT.java:746-747
         -> schema-evolution E2E explicitly disabled because Debezium PostgreSQL 1.9
            cannot emit DDL schema change events to consumers
   ```
   
   # Core review
   Compared with Daniel's previous latest-head review on `6619d4c437ed8746e01b9cbcd10ddb8579664fa3`, the new delta is only one line in the E2E:
   
   ```java
   @Disabled("Debezium PostgreSQL 1.9 cannot emit DDL schema change events to consumers.")
   ```
   
   Key findings:
   1. The production parser / resolver chain itself is still wired into the right place.
   2. The new follow-up change does not fix the feature-readiness gap; it confirms it.
   3. The repo is still pinned to `debezium.version = 1.9.8.Final`.
   4. Docs still advertise `schema-changes.enabled` as a supported user feature even though the only end-to-end path is now explicitly disabled for the current baseline.
   
   # Findings
   
   Issue 1: on the current Debezium 1.9.8.Final baseline, the PostgreSQL DDL schema-change user path is still unreachable, while docs and option contract still advertise it as supported
   - Location: `seatunnel-connectors-v2/connector-cdc/pom.xml:44`
   - Problem description:  
     `PostgresIncrementalSource.java:110-118` correctly installs `PostgresSchemaChangeResolver` into the consumer-side chain. But the latest head also adds `@Disabled("Debezium PostgreSQL 1.9 cannot emit DDL schema change events to consumers.")` to the schema-evolution E2E in `PostgresCDCIT.java:746-747`, while the repo remains pinned to `debezium.version = 1.9.8.Final` and the docs still present `schema-changes.enabled` as an available user-facing feature.
   - Potential risk:  
     Users can enable a feature that is documented as supported, but the actual PostgreSQL DDL event source is still unavailable on the current dependency baseline.
   - Best improvement suggestion:  
     Option A: upgrade to a Debezium baseline that really exposes PostgreSQL DDL schema-change events to consumers, re-enable the E2E, and then ship this as a supported feature.  
     Option B: if this round is only meant to land preparatory infrastructure, then narrow the docs / user-facing contract accordingly instead of presenting the feature as already available.
   - Severity: High
   - Already raised by others: No
   
   # Compatibility
   - Default behavior remains compatible because `schema-changes.enabled` stays `false`.
   - The risk is not default compatibility; it is the user-facing feature contract once the flag is enabled.
   
   # Tests / coverage
   - The parser/resolver tests are still useful and structurally stable.
   - The key gap is not flaky structure; it is that the schema-evolution E2E is now explicitly disabled on the current baseline.
   
   # CI status
   - GitHub currently reports:
     - `mergeable=MERGEABLE`
     - `mergeStateStatus=BLOCKED`
     - `Build=FAILURE`
   - I checked the top-level check metadata: it points to fork run `zhangshenghang/seatunnel` run `26275639691`, and that fork `Build` run is indeed failing. I did not fully root-cause that fork build failure in this pass, because issue 1 is already a source-level blocker independently of CI.
   
   ### Conclusion: can merge after fixes
   
   1. Blocking items
   - Issue 1: please do not ship this as a supported PostgreSQL CDC schema-evolution feature on the current pinned Debezium 1.9.8.Final baseline.
   
   2. Suggested non-blocking follow-up
   - No extra non-blocking items from my side beyond the main blocker above.
   
   Overall, I still like the code direction. But the latest head's new `@Disabled` line confirms that feature readiness and user-facing contract are still ahead of what the current dependency baseline can actually deliver.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@seatunnel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [Improve][Connector-V2][PostgreSQL-CDC] Prepare schema evolution parsing [seatunnel]

Posted by "zhangshenghang (via GitHub)" <gi...@apache.org>.
zhangshenghang commented on PR #10779:
URL: https://github.com/apache/seatunnel/pull/10779#issuecomment-5161310026

   Thanks @dybyte and @DanielLeens for pointing this out.
   
   I agree with the concern. With the current PostgreSQL `pgoutput` + Debezium 1.9 baseline, this PR should not assume that the original PostgreSQL DDL statement is available from the production WAL path. `pgoutput` exposes relation metadata updates rather than the raw DDL statement, so a real production schema-evolution implementation would need a different input path, most likely schema diffing from old/new table metadata, before this resolver can be wired into the runtime.
   
   Based on that, I have narrowed the PR to parser/resolver preparation only:
   
   - The PR title is now `Prepare schema evolution parsing`.
   - `schema-changes.enabled` is not exposed for PostgreSQL CDC.
   - `PostgresSourceConfigFactory` still sets `include.schema.changes=false`.
   - `PostgresIncrementalSource` does not wire `PostgresSchemaChangeResolver` into the row deserializer.
   - `SourceRecordUtils` still does not include PostgreSQL in the shared schema-change event key list.
   - The Debezium JSON schema-change E2E remains disabled for the Debezium PostgreSQL 1.9 limitation.
   
   So there is currently no production path claiming to consume a DDL string from `pgoutput`. The added parser/resolver code is meant as groundwork for a later PR that supplies a real PostgreSQL schema-change input, for example by comparing relation/table metadata and then mapping that into SeaTunnel schema-change events. I will keep this PR scoped to that preparatory boundary and avoid advertising it as supported PostgreSQL CDC schema evolution.
   
   Also, the latest `Build` is green now.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@seatunnel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [Improve][Connector-V2][PostgreSQL-CDC] Prepare schema evolution parsing [seatunnel]

Posted by "DanielLeens (via GitHub)" <gi...@apache.org>.
DanielLeens commented on PR #10779:
URL: https://github.com/apache/seatunnel/pull/10779#issuecomment-5120317753

   Hi @zhangshenghang, thanks again for the PostgreSQL CDC schema-evolution parsing work. This PR already had the important source-level review history, so I updated the original branch directly instead of moving the work elsewhere.
   
   I have refreshed this PR branch:
   
   - Merged the latest `apache/dev` into `zsh/postgres-cdc-schema-evolution`.
   - Resolved the only conflict in `PostgresCDCIT` by keeping both required imports: the PR's `@Disabled` marker for the Debezium DDL schema-change limitation, and the latest `dev` `@BeforeEach` cleanup for generated replication slots.
   - Kept the final PR scope to the PostgreSQL CDC schema-change parser/resolver and its tests/E2E wiring.
   - Ran scoped formatting: `./mvnw -nsu -Dmaven.gitcommitid.skip=true -pl seatunnel-connectors-v2/connector-cdc/connector-cdc-postgres,seatunnel-e2e/seatunnel-connector-v2-e2e/connector-cdc-postgres-e2e spotless:apply`.
   
   The PR now points to head `c2fb4c147fc4c09816f70f1fdcc2b496c96cbcef`, and GitHub reports it as mergeable again. The current checks have just been queued, so the remaining gate is the normal GitHub CI/review result. Appreciate the steady work on this one — keeping it alive in the same PR preserves all the review context. 🙏
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@seatunnel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org