SML0127 commented on code in PR #3448: URL: https://github.com/apache/flink-cdc/pull/3448#discussion_r1677153078
########## flink-cdc-connect/flink-cdc-source-connectors/flink-connector-mysql-cdc/src/test/java/org/apache/flink/cdc/connectors/mysql/source/assigners/MySqlSnapshotSplitAssignerTest.java: ########## @@ -416,6 +416,51 @@ public void testTableWithoutPrimaryKey() { } } + @Test + public void testAssignTableWithoutPrimaryKeyWithChunkKeyColumn() { + String tableWithoutPrimaryKey = "customers_no_pk"; + List<String> expected = + Arrays.asList( + "customers_no_pk null [462]", + "customers_no_pk [462] [823]", + "customers_no_pk [823] [1184]", + "customers_no_pk [1184] [1545]", + "customers_no_pk [1545] [1906]", + "customers_no_pk [1906] null"); + List<String> splits = + getTestAssignSnapshotSplits( + customerDatabase, + 4, + CHUNK_KEY_EVEN_DISTRIBUTION_FACTOR_UPPER_BOUND.defaultValue(), + CHUNK_KEY_EVEN_DISTRIBUTION_FACTOR_LOWER_BOUND.defaultValue(), + new String[] {tableWithoutPrimaryKey}, + "id"); + assertEquals(expected, splits); + } + + @Test + public void testAssignTableWithPrimaryKeyWithChunkKeyColumnNotInPrimaryKey() { + String tableWithoutPrimaryKey = "customers"; + List<String> expected = + Arrays.asList( + "customers null [user_12]", + "customers [user_12] [user_15]", + "customers [user_15] [user_18]", + "customers [user_18] [user_20]", + "customers [user_20] [user_4]", + "customers [user_4] [user_7]", + "customers [user_7] null"); + List<String> splits = + getTestAssignSnapshotSplits( + customerDatabase, + 4, + CHUNK_KEY_EVEN_DISTRIBUTION_FACTOR_UPPER_BOUND.defaultValue(), + CHUNK_KEY_EVEN_DISTRIBUTION_FACTOR_LOWER_BOUND.defaultValue(), + new String[] {tableWithoutPrimaryKey}, + "name"); + assertEquals(expected, splits); + } Review Comment: @yuxiqian I added test code using non-primary key columns as chunk key for table with primary keys. -- 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: issues-unsubscr...@flink.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org