branch-4.1: [Improve](StreamingJob) Support schema change for PostgreSQL streaming job #61182#61453
Merged
yiguolei merged 1 commit intobranch-4.1from Mar 19, 2026
Merged
Conversation
…g job (#61182) ### What problem does this PR solve? #### Summary Added Schema Change support to the CDC pipeline of PostgreSQL Streaming Jobs, enabling Doris target tables to automatically follow DDL changes (ADD COLUMN / DROP COLUMN) from upstream PostgreSQL without manual intervention. #### Background Unlike MySQL Binlog, PostgreSQL WAL does not contain explicit DDL events. Schema Changes can only be detected by diffing the afterSchema field in the DML record with the locally cached schema. #### Implementation Detection process (three stages): 1. First diff (memory, name comparison): Compares the afterSchema field name of the current DML record with the cached tableSchemas. If a difference is found, proceeds to the next step. 2. JDBC refresh: Fetches the current real-time schema via PostgreSQL JDBC (fresh). 3. Second diff (exact comparison): Based on the afterSchema (not fresh), it only processes column changes already perceived in the current DML record, avoiding premature execution of subsequent DDL changes for which no DML record has yet been generated. - ADD only → generates ALTER TABLE … ADD COLUMN - DROP only → generates ALTER TABLE … DROP COLUMN - ADD + DROP simultaneously → Rename Guard: If it's determined to be a potential column renaming, no DDL is executed; only the cache is updated, and a WARN log is printed prompting the user to manually execute RENAME in Doris. Idempotency: SchemaChangeManager silently handles "Can not add column which already exists" / "Column does not exist" errors, ensuring retry safety. #### Limitations - RENAME COLUMN not supported: If ADD + DROP simultaneously triggers Rename Guard, the DDL is skipped, requiring the user to manually execute ALTER TABLE … RENAME COLUMN in Doris. Data flow then automatically resumes. - MODIFY COLUMN type not supported: Type changes are not visible during the name diff stage, no DDL is generated, and the Doris column type remains unchanged. - MODIFY COLUMN is not supported: Column type changes are ignored by design. Since type modifications do not change column names, they cannot be detected during the name diff stage, and therefore no DDL will be generated.
Contributor
|
run buildall |
yiguolei
approved these changes
Mar 19, 2026
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.
Cherry-picked from #61182