Skip to content

branch-4.1: [Improve](StreamingJob) Support schema change for PostgreSQL streaming job #61182#61453

Merged
yiguolei merged 1 commit intobranch-4.1from
auto-pick-61182-branch-4.1
Mar 19, 2026
Merged

branch-4.1: [Improve](StreamingJob) Support schema change for PostgreSQL streaming job #61182#61453
yiguolei merged 1 commit intobranch-4.1from
auto-pick-61182-branch-4.1

Conversation

@github-actions
Copy link
Contributor

Cherry-picked from #61182

…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.
@github-actions github-actions bot requested a review from yiguolei as a code owner March 18, 2026 03:20
@yiguolei
Copy link
Contributor

run buildall

@yiguolei yiguolei closed this Mar 19, 2026
@yiguolei yiguolei reopened this Mar 19, 2026
@yiguolei yiguolei merged commit 497adc8 into branch-4.1 Mar 19, 2026
25 of 29 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants