VinaySagarGonabavi commented on code in PR #4279:
URL: https://github.com/apache/flink-cdc/pull/4279#discussion_r2881293828


##########
flink-cdc-runtime/src/main/java/org/apache/flink/cdc/runtime/operators/transform/PreTransformOperator.java:
##########
@@ -215,6 +220,24 @@ private CreateTableEvent cacheCreateTable(CreateTableEvent 
event) {
     private Optional<SchemaChangeEvent> cacheChangeSchema(SchemaChangeEvent 
event) {
         TableId tableId = event.tableId();
         PreTransformChangeInfo tableChangeInfo = 
preTransformChangeInfoMap.get(tableId);
+
+        // Filter out redundant AddColumnEvent columns that already exist in 
the schema
+        // to handle duplicate events from tools like gh-ost online schema 
migrations
+        if (event instanceof AddColumnEvent) {
+            AddColumnEvent addColumnEvent = (AddColumnEvent) event;
+            Schema currentSchema = tableChangeInfo.getSourceSchema();
+            Optional<AddColumnEvent> filtered =
+                    SchemaUtils.filterRedundantAddColumns(currentSchema, 
addColumnEvent);
+            if (!filtered.isPresent()) {
+                LOG.debug(
+                        "Skipping fully redundant AddColumnEvent for table {} "
+                                + "- all columns already exist",
+                        tableId);
+                return Optional.empty();
+            }
+            event = filtered.get();
+        }

Review Comment:
   Removed `preTransformProcessorMap.remove(tableId)` before 
`cacheChangeSchema()`. Now the processor stays intact on the filtered path and 
gets overwritten via `cachePreTransformProcessor()` on the non-filtered path



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

Reply via email to