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


##########
fs_brokers/cdc_client/src/test/java/org/apache/doris/cdcclient/source/reader/mysql/MySqlSourceReaderTest.java:
##########
@@ -115,6 +125,44 @@ void mysqlConfigCanDisableSchemaChanges() throws Exception 
{
         assertFalse(config.isIncludeSchemaChanges());
     }
 
+    @Test
+    void snapshotSplitContainsOnlyCurrentTableSchema() throws Exception {
+        TableId tableId = TableId.parse("testdb.orders");
+        TableId otherTableId = TableId.parse("testdb.other_orders");
+        TableChanges.TableChange tableChange = tableChange(tableId, "pk");
+        Map<TableId, TableChanges.TableChange> tableSchemas = new HashMap<>();
+        tableSchemas.put(tableId, tableChange);
+        tableSchemas.put(otherTableId, tableChange(otherTableId, "other_id"));
+
+        MySqlSourceReader reader =
+                new MySqlSourceReader() {
+                    @Override
+                    protected Class<?> probeSplitKeyClass(
+                            TableId ignoredTableId,
+                            Column ignoredSplitColumn,
+                            JobBaseConfig ignoredJobConfig) {
+                        return Integer.class;
+                    }
+                };
+        reader.setTableSchemas(tableSchemas);
+
+        Method method =
+                MySqlSourceReader.class.getDeclaredMethod(
+                        "createSnapshotSplit", Map.class, JobBaseConfig.class);
+        method.setAccessible(true);
+        MySqlSnapshotSplit split =
+                (MySqlSnapshotSplit)
+                        method.invoke(
+                                reader,
+                                snapshotOffset("testdb.orders", "pk"),
+                                new JobBaseConfig("job-1", "MYSQL", Map.of(), 
null));
+
+        assertEquals(tableId, split.getTableId());
+        assertEquals(Map.of(tableId, tableChange), split.getTableSchemas());
+        assertFalse(split.getTableSchemas().containsKey(otherTableId));
+        assertEquals(tableSchemas, reader.getTableSchemas());

Review Comment:
   These are the same mutable map instance: `setTableSchemas` stores the 
supplied reference, so if `createSnapshotSplit` narrowed it in place, both 
sides would change together and this assertion would still pass. That would 
leave the later global binlog/stream split without the other table's schema. 
Assert the independent invariant instead:
   
   ```suggestion
           assertEquals(2, reader.getTableSchemas().size());
           assertTrue(reader.getTableSchemas().containsKey(otherTableId));
   ```
   
   Please mirror the same assertion in `PostgresSourceReaderTest`.
   



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