github-actions[bot] commented on code in PR #64850:
URL: https://github.com/apache/doris/pull/64850#discussion_r3473353065


##########
fs_brokers/cdc_client/src/main/java/org/apache/doris/cdcclient/source/deserialize/PostgresDebeziumJsonDeserializer.java:
##########
@@ -223,45 +179,46 @@ public DeserializeResult deserialize(Map<String, String> 
context, SourceRecord r
                             db, resolveTargetTable(tableId.table()), colName));
         }
 
-        for (Column col : pgAdded) {
+        for (Column col : added) {
             if (excludedCols.contains(col.name())) {
-                // The column is excluded from sync — Doris table does not 
have it,
-                // so skip the ADD DDL.
-                // case: An excluded column was dropped and then re-added.
                 LOG.info(
-                        "[SCHEMA-CHANGE] Table {}: added column '{}' is 
excluded from sync,"
-                                + " skipping ADD DDL",
+                        "[SCHEMA-CHANGE] Table {}: added column '{}' is 
excluded, skipping ADD",
                         tableId.identifier(),
                         col.name());
                 continue;
             }
             String colType = SchemaChangeHelper.columnToDorisType(col);
-            String nullable = col.isOptional() ? "" : " NOT NULL";
-            // pgAdded only contains columns present in afterSchema, so field 
lookup is safe.
-            // afterSchema.defaultValue() returns an already-deserialized Java 
object
-            // (e.g. String "hello", Integer 42) — no PG SQL cast suffix to 
strip.
-            // PG WAL DML records do not carry column comment metadata.
-            Object defaultObj = 
afterSchema.field(col.name()).schema().defaultValue();
+            String defaultValue = 
stripPgDefault(col.defaultValueExpression().orElse(null));
+            String nullable;
+            if (!col.isOptional() && defaultValue == null) {
+                // NOT NULL without a usable default would fail ADD COLUMN 
against existing Doris

Review Comment:
   This fallback silently changes the result for PostgreSQL columns that have a 
DEFAULT expression we do not understand. For example the new test case uses 
`date NOT NULL DEFAULT current_date`: PostgreSQL backfills existing rows with 
the statement date, but `stripPgDefault` returns null, this branch drops `NOT 
NULL`, emits `ADD COLUMN d DATE` with no DEFAULT, and then `updatedSchemas` 
advances to the fresh PG schema. The rows already loaded into Doris will remain 
NULL while PG has non-null default values, and future retries will not revisit 
the DDL because the baseline has advanced. Please either map the default safely 
or fail/skip automatic DDL without advancing the baseline so this case requires 
manual handling instead of silent divergence.



-- 
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