DongLiang-0 commented on code in PR #205:
URL: 
https://github.com/apache/doris-flink-connector/pull/205#discussion_r1352569374


##########
flink-doris-connector/src/main/java/org/apache/doris/flink/sink/writer/JsonDebeziumSchemaSerializer.java:
##########
@@ -224,44 +235,49 @@ public List<String> extractDDLList(JsonNode record) 
throws JsonProcessingExcepti
         JsonNode historyRecord = extractHistoryRecord(record);
         JsonNode tableChanges = historyRecord.get("tableChanges");
         String ddl = extractJsonNode(historyRecord, "ddl");
-        if(Objects.isNull(tableChanges) || Objects.isNull(ddl)){
+        if (Objects.isNull(tableChanges) || Objects.isNull(ddl)) {
             return new ArrayList<>();
         }
         LOG.debug("received debezium ddl :{}", ddl);
         JsonNode tableChange = tableChanges.get(0);
-        Matcher matcher = addDropDDLPattern.matcher(ddl);
-        if (Objects.isNull(tableChange)|| 
!tableChange.get("type").asText().equals("ALTER") || !matcher.find()) {
+        if (Objects.isNull(tableChange) || 
!tableChange.get("type").asText().equals("ALTER")) {
             return null;
         }
 
         JsonNode columns = tableChange.get("table").get("columns");
         if (firstSchemaChange) {
+            sourceConnector = 
SourceConnector.valueOf(record.get("source").get("connector").asText().toUpperCase());
             fillOriginSchema(columns);
         }
         Map<String, FieldSchema> updateFiledSchema = new LinkedHashMap<>();
         for (JsonNode column : columns) {
             buildFieldSchema(updateFiledSchema, column);
         }
         SchemaChangeHelper.compareSchema(updateFiledSchema, 
originFieldSchemaMap);
+        // In order to avoid operations such as rename or change, which may 
lead to the accidental deletion of the doris column.
+        Matcher matcher = addDropDDLPattern.matcher(ddl);
+        if (!matcher.find()) {
+            return null;
+        }

Review Comment:
   Thanks for your suggestion, I have added it.



-- 
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: commits-unsubscr...@doris.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org
For additional commands, e-mail: commits-h...@doris.apache.org

Reply via email to