JNSimba opened a new pull request, #61182:
URL: https://github.com/apache/doris/pull/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.
   
   ### Release note
   
   None
   
   ### Check List (For Author)
   
   - Test <!-- At least one of them must be included. -->
       - [ ] Regression test
       - [ ] Unit Test
       - [ ] Manual test (add detailed scripts or steps below)
       - [ ] No need to test or manual test. Explain why:
           - [ ] This is a refactor/code format and no logic has been changed.
           - [ ] Previous test can cover this change.
           - [ ] No code files have been changed.
           - [ ] Other reason <!-- Add your reason?  -->
   
   - Behavior changed:
       - [ ] No.
       - [ ] Yes. <!-- Explain the behavior change -->
   
   - Does this need documentation?
       - [ ] No.
       - [ ] Yes. <!-- Add document PR link here. eg: 
https://github.com/apache/doris-website/pull/1214 -->
   
   ### Check List (For Reviewer who merge this PR)
   
   - [ ] Confirm the release note
   - [ ] Confirm test cases
   - [ ] Confirm document
   - [ ] Add branch pick label <!-- Add branch pick label that this PR should 
merge into -->
   
   


-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to