This is an automated email from the ASF dual-hosted git repository.
kunni pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/flink-cdc.git
The following commit(s) were added to refs/heads/master by this push:
new e4cf02756 [FLINK-39329][MySQL] Improve error message for tables
without primary key in incremental snapshot (#4342)
e4cf02756 is described below
commit e4cf02756321682710aa9d80adf549f1ffd3d3f2
Author: EricZeng <[email protected]>
AuthorDate: Fri Mar 27 16:57:34 2026 +0800
[FLINK-39329][MySQL] Improve error message for tables without primary key
in incremental snapshot (#4342)
---
.../apache/flink/cdc/connectors/mysql/source/utils/ChunkUtils.java | 5 ++++-
.../mysql/source/assigners/MySqlSnapshotSplitAssignerTest.java | 2 +-
2 files changed, 5 insertions(+), 2 deletions(-)
diff --git
a/flink-cdc-connect/flink-cdc-source-connectors/flink-connector-mysql-cdc/src/main/java/org/apache/flink/cdc/connectors/mysql/source/utils/ChunkUtils.java
b/flink-cdc-connect/flink-cdc-source-connectors/flink-connector-mysql-cdc/src/main/java/org/apache/flink/cdc/connectors/mysql/source/utils/ChunkUtils.java
index 794abd2b5..251976da3 100644
---
a/flink-cdc-connect/flink-cdc-source-connectors/flink-connector-mysql-cdc/src/main/java/org/apache/flink/cdc/connectors/mysql/source/utils/ChunkUtils.java
+++
b/flink-cdc-connect/flink-cdc-source-connectors/flink-connector-mysql-cdc/src/main/java/org/apache/flink/cdc/connectors/mysql/source/utils/ChunkUtils.java
@@ -67,7 +67,10 @@ public class ChunkUtils {
String chunkKeyColumn = findChunkKeyColumn(table.id(),
chunkKeyColumns);
if (primaryKeys.isEmpty() && chunkKeyColumn == null) {
throw new ValidationException(
- "To use incremental snapshot,
'scan.incremental.snapshot.chunk.key-column' must be set when the table doesn't
have primary keys.");
+ String.format(
+ "Table '%s' has no primary key. To use incremental
snapshot, "
+ + "please set
'scan.incremental.snapshot.chunk.key-column' for this table.",
+ table.id()));
}
List<Column> searchColumns = table.columns();
diff --git
a/flink-cdc-connect/flink-cdc-source-connectors/flink-connector-mysql-cdc/src/test/java/org/apache/flink/cdc/connectors/mysql/source/assigners/MySqlSnapshotSplitAssignerTest.java
b/flink-cdc-connect/flink-cdc-source-connectors/flink-connector-mysql-cdc/src/test/java/org/apache/flink/cdc/connectors/mysql/source/assigners/MySqlSnapshotSplitAssignerTest.java
index ca5dff5bd..c6cf80792 100644
---
a/flink-cdc-connect/flink-cdc-source-connectors/flink-connector-mysql-cdc/src/test/java/org/apache/flink/cdc/connectors/mysql/source/assigners/MySqlSnapshotSplitAssignerTest.java
+++
b/flink-cdc-connect/flink-cdc-source-connectors/flink-connector-mysql-cdc/src/test/java/org/apache/flink/cdc/connectors/mysql/source/assigners/MySqlSnapshotSplitAssignerTest.java
@@ -411,7 +411,7 @@ class MySqlSnapshotSplitAssignerTest extends
MySqlSourceTestBase {
new String[] {tableWithoutPrimaryKey});
})
.hasStackTraceContaining(
- "To use incremental snapshot,
'scan.incremental.snapshot.chunk.key-column' must be set when the table doesn't
have primary keys.");
+ "has no primary key. To use incremental snapshot,
please set 'scan.incremental.snapshot.chunk.key-column' for this table.");
}
@Test