You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@inlong.apache.org by GitBox <gi...@apache.org> on 2022/11/01 11:34:43 UTC

[GitHub] [inlong] yunqingmoswu opened a new pull request, #6358: [INLONG-6353][Sort] Fix delete event handle error for doris connector

yunqingmoswu opened a new pull request, #6358:
URL: https://github.com/apache/inlong/pull/6358

   ### Prepare a Pull Request
   *(Change the title refer to the following example)*
   
   Title: [INLONG-6353][Sort] Fix delete event handle error for doris connector
   
   *(The following *XYZ* should be replaced by the actual [GitHub Issue](https://github.com/apache/inlong/issues) number)*
   
   Fixes #6353
   
   ### Motivation
   
   Fix delete event handle error for doris connector
   
   ### Modifications
   
   1. Add delete event support in DorisDynamicSchemaOutputFormat. 
   
   ### Verifying this change
   
   *(Please pick either of the following options)*
   
   - [ ] This change is a trivial rework/code cleanup without any test coverage.
   
   - [x] This change is already covered by existing tests, such as:
     *(please describe tests)*
   
   - [ ] This change added tests and can be verified as follows:
   
     *(example:)*
     - *Added integration tests for end-to-end deployment with large payloads (10MB)*
     - *Extended integration test for recovery after broker failure*
   
   ### Documentation
   
     - Does this pull request introduce a new feature? (yes / no)
     - If yes, how is the feature documented? (not applicable / docs / JavaDocs / not documented)
     - If a feature is not applicable for documentation, explain why?
     - If a feature is not documented yet in this PR, please create a follow-up issue for adding the documentation
   


-- 
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-unsubscribe@inlong.apache.org

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


[GitHub] [inlong] healchow commented on a diff in pull request #6358: [INLONG-6353][Sort] Fix delete event handle error for doris connector

Posted by GitBox <gi...@apache.org>.
healchow commented on code in PR #6358:
URL: https://github.com/apache/inlong/pull/6358#discussion_r1011114184


##########
inlong-sort/sort-connectors/base/src/main/java/org/apache/inlong/sort/base/format/DebeziumJsonDynamicSchemaFormat.java:
##########
@@ -224,6 +224,9 @@ public RowType extractSchema(JsonNode data, List<String> pkNames) {
             return extractSchemaFromExtractInfo(data, pkNames);
         } catch (IllegalArgumentException e) {
             JsonNode schema = data.get(SCHEMA);
+            if (schema == null) {
+                throw new IllegalArgumentException(String.format("Error schema: %s.", data));

Review Comment:
   ```suggestion
                   throw new IllegalArgumentException(String.format("Not found schema from: %s", data));
   ```



-- 
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-unsubscribe@inlong.apache.org

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


[GitHub] [inlong] EMsnap commented on a diff in pull request #6358: [INLONG-6353][Sort] Fix delete event handle error for doris connector

Posted by GitBox <gi...@apache.org>.
EMsnap commented on code in PR #6358:
URL: https://github.com/apache/inlong/pull/6358#discussion_r1011161522


##########
inlong-sort/sort-connectors/doris/src/main/java/org/apache/inlong/sort/doris/table/DorisDynamicSchemaOutputFormat.java:
##########
@@ -277,6 +284,53 @@ private void addBatch(T row) throws IOException {
         }
     }
 
+    private void handleColumnsChange(String tableIdentifier, JsonNode rootNode, JsonNode physicalData) {
+        String columns = parseColumns(rootNode, physicalData);
+        String oldColumns = columnsMap.get(tableIdentifier);
+        if (columns == null && oldColumns != null || (columns != null && !columns.equals(oldColumns))) {
+            flushSingleTable(tableIdentifier, batchMap.get(tableIdentifier));
+            if (!errorTables.contains(tableIdentifier)) {
+                columnsMap.put(tableIdentifier, columns);
+            } else {
+                batchMap.remove(tableIdentifier);
+                columnsMap.remove(tableIdentifier);
+                errorTables.remove(tableIdentifier);
+            }
+        }
+    }
+
+    private String parseColumns(JsonNode rootNode, JsonNode physicalData) {
+        // Add column key when fieldNames is not empty
+        Iterator<String> fieldNames = null;
+        try {
+            RowType rowType = jsonDynamicSchemaFormat.extractSchema(rootNode);
+            if (rowType != null) {
+                fieldNames = rowType.getFieldNames().listIterator();
+            }
+        } catch (IllegalArgumentException e) {
+            LOG.warn("extract schema failed", e);
+            // Extract schema from physicalData
+            JsonNode first = physicalData.isArray() ? physicalData.get(0) : physicalData;
+            // Add column key when fieldNames is not empty
+            fieldNames = first.fieldNames();
+        }
+        if (fieldNames != null && fieldNames.hasNext()) {
+            StringBuilder sb = new StringBuilder();

Review Comment:
   a method for this logic to construct doris columns would be better 



-- 
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-unsubscribe@inlong.apache.org

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


[GitHub] [inlong] healchow commented on a diff in pull request #6358: [INLONG-6353][Sort] Fix delete event handle error for doris connector

Posted by GitBox <gi...@apache.org>.
healchow commented on code in PR #6358:
URL: https://github.com/apache/inlong/pull/6358#discussion_r1011112092


##########
inlong-sort/sort-connectors/base/src/main/java/org/apache/inlong/sort/base/format/CanalJsonDynamicSchemaFormat.java:
##########
@@ -113,6 +113,9 @@ public boolean extractDDLFlag(JsonNode data) {
     @Override
     public RowType extractSchema(JsonNode data, List<String> pkNames) {
         JsonNode schema = data.get(SCHEMA);
+        if (schema == null) {
+            throw new IllegalArgumentException(String.format("Error schema: %s.", data));

Review Comment:
   Personally, I think the 'Error schema' is not accurate enough.
   
   ```suggestion
               throw new IllegalArgumentException(String.format("Not found schema from: %s", data));
   ```



-- 
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-unsubscribe@inlong.apache.org

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


[GitHub] [inlong] yunqingmoswu merged pull request #6358: [INLONG-6353][Sort] Fix delete event handle error for doris connector

Posted by GitBox <gi...@apache.org>.
yunqingmoswu merged PR #6358:
URL: https://github.com/apache/inlong/pull/6358


-- 
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-unsubscribe@inlong.apache.org

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


[GitHub] [inlong] yunqingmoswu closed pull request #6358: [INLONG-6353][Sort] Fix delete event handle error for doris connector

Posted by GitBox <gi...@apache.org>.
yunqingmoswu closed pull request #6358: [INLONG-6353][Sort] Fix delete event handle error for doris connector
URL: https://github.com/apache/inlong/pull/6358


-- 
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-unsubscribe@inlong.apache.org

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


[GitHub] [inlong] healchow commented on a diff in pull request #6358: [INLONG-6353][Sort] Fix delete event handle error for doris connector

Posted by GitBox <gi...@apache.org>.
healchow commented on code in PR #6358:
URL: https://github.com/apache/inlong/pull/6358#discussion_r1011112092


##########
inlong-sort/sort-connectors/base/src/main/java/org/apache/inlong/sort/base/format/CanalJsonDynamicSchemaFormat.java:
##########
@@ -113,6 +113,9 @@ public boolean extractDDLFlag(JsonNode data) {
     @Override
     public RowType extractSchema(JsonNode data, List<String> pkNames) {
         JsonNode schema = data.get(SCHEMA);
+        if (schema == null) {
+            throw new IllegalArgumentException(String.format("Error schema: %s.", data));

Review Comment:
   ```suggestion
               throw new IllegalArgumentException(String.format("Not found schema from: %s", data));
   ```



-- 
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-unsubscribe@inlong.apache.org

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