Copilot commented on code in PR #64850:
URL: https://github.com/apache/doris/pull/64850#discussion_r3473312351
##########
fs_brokers/cdc_client/src/main/java/org/apache/doris/cdcclient/source/deserialize/PostgresDebeziumJsonDeserializer.java:
##########
@@ -271,4 +228,77 @@ private TableId extractTableId(SourceRecord record) {
String tableName = source.getString(TABLE_NAME_KEY);
return new TableId(null, schemaName, tableName);
}
+
+ /**
+ * Convert a raw PostgreSQL default-value expression into a plain value
usable by {@link
+ * SchemaChangeHelper#quoteDefaultValue}. Best-effort: only string
literals, numeric/boolean
+ * literals and the common {@code now()/current_timestamp/localtimestamp}
forms are mapped; any
+ * other expression (sequence-backed serial, other function calls,
unrecognized keywords like
+ * {@code current_date}) degrades to no static default rather than risk
emitting a wrong DEFAULT
+ * clause. The column is still populated by incoming DML; only the Doris
DEFAULT is omitted.
+ */
+ private static String stripPgDefault(String expr) {
+ if (expr == null) {
+ return null;
+ }
+ String e = expr.trim();
+ if (e.isEmpty()) {
+ return null;
+ }
+ String lower = e.toLowerCase();
+ if (lower.contains("nextval(")) {
+ return null; // serial / identity — no static default
+ }
+ if (lower.startsWith("now()")
+ || lower.startsWith("current_timestamp")
+ || lower.startsWith("localtimestamp")) {
+ return "CURRENT_TIMESTAMP";
+ }
Review Comment:
stripPgDefault() maps any expression that *starts with*
`now()/current_timestamp/localtimestamp` to `CURRENT_TIMESTAMP`. This will
incorrectly treat more complex expressions like `current_timestamp AT TIME ZONE
'UTC'` (or similar prefixes) as a simple timestamp default, potentially
emitting a semantically wrong Doris `DEFAULT CURRENT_TIMESTAMP` instead of
degrading to `null` as the method’s Javadoc promises for unsupported
expressions.
Consider only mapping exact literals (optionally with precision and/or a
trailing `::type` cast), and treat anything else as unsupported.
--
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]