HongJunDW opened a new issue, #13441: URL: https://github.com/apache/seatunnel/issues/13441
### Search before asking - [x] I had searched in the [issues](https://github.com/apache/seatunnel/issues?q=is%3Aissue+label%3A%22bug%22) and found no similar issues. ### What happened ### Search before asking - [x] I had searched in the [issues](https://github.com/apache/seatunnel/issues?q=is%3Aissue+label%3A%22bug%22) and found no similar issues. ### What happened MySQL-CDC -> Jdbc(MySQL) streaming job with schema evolution enabled. After the source table adds a new column with a valid `DATETIME DEFAULT '1970-01-01 00:00:00'`, SeaTunnel replays the DDL on the target but renders the default as `'0'`, and the target MySQL rejects it with error 1067. The job then fails and recovers; because the target column is still missing, the same invalid `ADD COLUMN` is replayed on every recovery (observed every ~3.5 minutes), so the pipeline never catches up. **Source DDL** ```sql ALTER TABLE `src_db`.`src_t` ADD COLUMN `col_a` DATETIME NOT NULL DEFAULT '1970-01-01 00:00:00' COMMENT 'updated time'; ``` **DDL actually executed on the target (from SeaTunnel log)** ```text INFO [o.a.s.c.s.j.i.d.JdbcDialect] - Executing add column SQL: ALTER TABLE `dst_db`.`dst_t` ADD COLUMN `col_a` DATETIME NOT NULL DEFAULT '0' COMMENT 'updated time' ``` **Target MySQL error** ```text java.sql.SQLSyntaxErrorException: Invalid default value for 'col_a' at ... JdbcDialect.applySchemaChange(JdbcDialect.java:...) ``` **Environment details** - Target MySQL: MySQL 8.0.x, `sql_mode` includes `STRICT_TRANS_TABLES` (default); `SELECT @@sql_mode, @@version;` output attached below. - Source MySQL: 8.0.x, binlog ROW. **Steps to reproduce** 1. Create source table `src_t (id INT PRIMARY KEY, ...)`; start a MySQL-CDC -> Jdbc(MySQL) streaming job with `schema-changes.enabled = true`. 2. On the source, run the `ALTER TABLE ... ADD COLUMN col_a DATETIME NOT NULL DEFAULT '1970-01-01 00:00:00'` above. 3. Observe the target `ALTER TABLE ... ADD COLUMN ... DATETIME NOT NULL DEFAULT '0'` and the 1067 error in the SeaTunnel log. 4. The job restarts/recoveries and replays the same DDL; the column is never added. **Root cause analysis (source level, reproducible on 3.0.0 / 3.1.0 / current dev)** The default value loses its SQL literal form before the sink renders the DDL: 1. `connector-cdc-mysql` `MySqlTypeUtils.convertToSeaTunnelColumn()` takes `column.defaultValueExpression()` and, for anything outside the `CURRENT_TIMESTAMP/TRUE/FALSE` whitelist, calls Debezium `MySqlDefaultValueConverter.parseDefaultValue()`. 2. That API returns the value in Debezium's Kafka Connect logical-type representation: for MySQL temporal columns the value goes through `io.debezium.time.Timestamp.toEpochMillis()` (UTC), so `'1970-01-01 00:00:00'` becomes `Long 0`. 3. `Column.defaultValue` is then `0`; on the sink side `JdbcDialect.applySchemaChange(AlterTableAddColumnEvent)` renders `DEFAULT` only when source and sink dialect match (MySQL -> MySQL here), `MysqlDialect.needsQuotesWithDefaultValue(DATETIME)` is `true`, `DefaultValueUtils.isMysqlSpecialDefaultValue(0)` is `false`, so the final DDL is `DEFAULT '0'`. 4. MySQL rejects `'0'` for a DATETIME column with 1067, and recovery replays the same event. This is not specific to the 1970 epoch value: any literal DATE/TIME/DATETIME/TIMESTAMP default is serialized to an epoch number. For example `'2020-01-01 00:00:00'` is rendered as `DEFAULT '1577836800000'` (also 1067). Related earlier report/design notes: #13217 and STIP-46 #13372 (which explicitly lists "how defaults behave during CDC-driven DDL evolution" as out of scope for STIP v1). Affected code (same in `v3.0.0`, `3.1.0` and current `dev`, Debezium pinned to 1.9.8.Final in all): - `seatunnel-connectors-v2/connector-cdc/connector-cdc-mysql/src/main/java/org/apache/seatunnel/connectors/seatunnel/cdc/mysql/utils/MySqlTypeUtils.java` (v3.0.0 L78-L85) - `seatunnel-connectors-v2/connector-jdbc/src/main/java/org/apache/seatunnel/connectors/seatunnel/jdbc/internal/dialect/JdbcDialect.java` (`applySchemaChange`, `sqlClauseWithDefaultValue`) - `seatunnel-connectors-v2/connector-jdbc/src/main/java/org/apache/seatunnel/connectors/seatunnel/jdbc/internal/dialect/mysql/MysqlDialect.java` (`needsQuotesWithDefaultValue`) - `seatunnel-connectors-v2/connector-jdbc/src/main/java/org/apache/seatunnel/connectors/seatunnel/jdbc/utils/DefaultValueUtils.java` Possible fix directions: preserve the raw default-value expression for literal defaults on the CDC path (strip quotes/charset introducer) instead of storing the Connect logical value; or convert epoch numbers back to `yyyy-MM-dd HH:mm:ss` only when rendering DDL for temporal columns. ### SeaTunnel Version 3.0.0 (verified the same code path and Debezium version exist in 3.1.0 and on current dev; upgrading to 3.1.0 does not fix it). ### SeaTunnel Config ```conf conf env { job.mode = "STREAMING" checkpoint.interval = 10000 } source { MySQL-CDC { base-url = "jdbc:mysql://src-host:3306/src_db" username = "***" password = "***" table-names = ["src_db.src_t"] schema-changes.enabled = true } } sink { Jdbc { url = "jdbc:mysql://dst-host:3306/dst_db" driver = "com.mysql.cj.jdbc.Driver" user = "***" password = "***" schema_save_mode = "EXIST_DATA_APPEND" data_save_mode = "APPEND_DATA" } } ``` ### Running Command ```shell ./bin/seatunnel.sh -c config/mysqlcdc2mysql.conf -e local # or submitted to the Zeta cluster via REST/CLI ``` ### Error Exception ```log 2026-11-25 10:28:13,511 INFO [o.a.s.c.s.j.i.d.JdbcDialect] - Executing add column SQL: ALTER TABLE `dst_db`.`dst_t` ADD COLUMN `col_a` DATETIME NOT NULL DEFAULT '0' COMMENT 'updated time' 2026-11-25 10:28:13,549 ERROR [...] - ... Caused by: java.sql.SQLSyntaxErrorException: Invalid default value for 'col_a' at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:...) at org.apache.seatunnel.connectors.seatunnel.jdbc.internal.dialect.JdbcDialect.applySchemaChange(JdbcDialect.java:...) Same DDL is replayed at 10:32:01 and 10:35:39 after job recovery. ### Zeta or Flink or Spark Version Zeta (SeaTunnel 3.0.0, Java 8; also reproducible on 3.1.0 / Java 11, same code path). ### Java or Scala Version Java 8 (SeaTunnel 3.0.0). 3.1.0 requires Java 11+; behavior unchanged. ### Screenshots N/A (logs above). ### Are you willing to submit PR? - [ ] Yes I am willing to submit a PR! ### Code of Conduct - [x] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct) ``` ### Zeta or Flink or Spark Version _No response_ ### Java or Scala Version _No response_ ### Screenshots _No response_ ### Are you willing to submit PR? - [ ] Yes I am willing to submit a PR! ### Code of Conduct - [x] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct) -- 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]
