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/06/14 09:47:51 UTC

[GitHub] [incubator-inlong] Oneal65 opened a new pull request, #4666: [INLONG-4665][Sort] The primary key must be _id in mongoDB CDC Connector

Oneal65 opened a new pull request, #4666:
URL: https://github.com/apache/incubator-inlong/pull/4666

   
   - Fixes #4665 
   
   ### Motivation
   
   The primary key must be _id in mongoDB CDC Connector
   
   ### Modifications
   
   modify the MongoExtractNode constructor
   
   ### Verifying this change
   
   *(Please pick either of the following options)*
   
   - [ ] This change is a trivial rework/code cleanup without any test coverage.
   
   - [ ] 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] [incubator-inlong] healchow commented on a diff in pull request #4666: [INLONG-4665][Sort] The primary key must be _id in mongoDB CDC Connector

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


##########
inlong-sort/sort-common/src/main/java/org/apache/inlong/sort/protocol/node/extract/MongoExtractNode.java:
##########
@@ -61,23 +63,28 @@ public class MongoExtractNode extends ExtractNode implements Serializable {
 
     @JsonCreator
     public MongoExtractNode(@JsonProperty("id") String id,
-        @JsonProperty("name") String name,
-        @JsonProperty("fields") List<FieldInfo> fields,
-        @Nullable @JsonProperty("watermarkField") WatermarkField waterMarkField,
-        @JsonProperty("properties") Map<String, String> properties,
-        @JsonProperty("primaryKey") String primaryKey,
-        @JsonProperty("collection") @Nonnull String collection,
-        @JsonProperty("hostname") String hostname,
-        @JsonProperty("username") String username,
-        @JsonProperty("password") String password,
-        @JsonProperty("database") String database) {
+            @JsonProperty("name") String name,
+            @JsonProperty("fields") List<FieldInfo> fields,
+            @Nullable @JsonProperty("watermarkField") WatermarkField waterMarkField,
+            @JsonProperty("properties") Map<String, String> properties,
+            @JsonProperty("collection") @Nonnull String collection,
+            @JsonProperty("hostname") String hostname,
+            @JsonProperty("username") String username,
+            @JsonProperty("password") String password,
+            @JsonProperty("database") String database) {
         super(id, name, fields, waterMarkField, properties);
+        if (fields.stream().noneMatch(m -> m.getName().equals("_id"))) {
+            List<FieldInfo> allFields = new ArrayList<>(fields);
+            allFields.add(new FieldInfo("_id", new StringFormatInfo()));
+            this.setFields(allFields);
+        }
         this.collection = Preconditions.checkNotNull(collection, "collection is null");
         this.hosts = Preconditions.checkNotNull(hostname, "hostname is null");
         this.username = Preconditions.checkNotNull(username, "username is null");
         this.password = Preconditions.checkNotNull(password, "password is null");
         this.database = Preconditions.checkNotNull(database, "database is null");
-        this.primaryKey = primaryKey;
+        // the primaryKey must be "_id"
+        this.primaryKey = "_id";

Review Comment:
   Suggest using a String constant for `_id`, and add a link for why the primary key must be `_id`.



-- 
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] [incubator-inlong] healchow commented on a diff in pull request #4666: [INLONG-4665][Sort] The primary key must be _id in mongoDB CDC Connector

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


##########
inlong-manager/manager-service/src/main/java/org/apache/inlong/manager/service/sort/util/ExtractNodeUtils.java:
##########
@@ -385,7 +385,6 @@ public static MongoExtractNode createExtractNode(MongoDBSource source) {
                 fieldInfos,
                 null,
                 properties,
-                source.getPrimaryKey(),

Review Comment:
   OK, I'll remove them later.



-- 
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] [incubator-inlong] Oneal65 commented on a diff in pull request #4666: [INLONG-4665][Sort] The primary key must be _id in mongoDB CDC Connector

Posted by GitBox <gi...@apache.org>.
Oneal65 commented on code in PR #4666:
URL: https://github.com/apache/incubator-inlong/pull/4666#discussion_r897968869


##########
inlong-manager/manager-service/src/main/java/org/apache/inlong/manager/service/sort/util/ExtractNodeUtils.java:
##########
@@ -385,7 +385,6 @@ public static MongoExtractNode createExtractNode(MongoDBSource source) {
                 fieldInfos,
                 null,
                 properties,
-                source.getPrimaryKey(),

Review Comment:
   Yes, you can.



-- 
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] [incubator-inlong] healchow merged pull request #4666: [INLONG-4665][Sort] The primary key must be _id in mongoDB CDC Connector

Posted by GitBox <gi...@apache.org>.
healchow merged PR #4666:
URL: https://github.com/apache/incubator-inlong/pull/4666


-- 
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] [incubator-inlong] gong commented on a diff in pull request #4666: [INLONG-4665][Sort] The primary key must be _id in mongoDB CDC Connector

Posted by GitBox <gi...@apache.org>.
gong commented on code in PR #4666:
URL: https://github.com/apache/incubator-inlong/pull/4666#discussion_r896645972


##########
inlong-sort/sort-common/src/main/java/org/apache/inlong/sort/protocol/node/extract/MongoExtractNode.java:
##########
@@ -61,23 +61,23 @@ public class MongoExtractNode extends ExtractNode implements Serializable {
 
     @JsonCreator
     public MongoExtractNode(@JsonProperty("id") String id,
-        @JsonProperty("name") String name,
-        @JsonProperty("fields") List<FieldInfo> fields,
-        @Nullable @JsonProperty("watermarkField") WatermarkField waterMarkField,
-        @JsonProperty("properties") Map<String, String> properties,
-        @JsonProperty("primaryKey") String primaryKey,
-        @JsonProperty("collection") @Nonnull String collection,
-        @JsonProperty("hostname") String hostname,
-        @JsonProperty("username") String username,
-        @JsonProperty("password") String password,
-        @JsonProperty("database") String database) {
+            @JsonProperty("name") String name,
+            @JsonProperty("fields") List<FieldInfo> fields,
+            @Nullable @JsonProperty("watermarkField") WatermarkField waterMarkField,
+            @JsonProperty("properties") Map<String, String> properties,
+            @JsonProperty("collection") @Nonnull String collection,
+            @JsonProperty("hostname") String hostname,
+            @JsonProperty("username") String username,
+            @JsonProperty("password") String password,
+            @JsonProperty("database") String database) {
         super(id, name, fields, waterMarkField, properties);
         this.collection = Preconditions.checkNotNull(collection, "collection is null");
         this.hosts = Preconditions.checkNotNull(hostname, "hostname is null");
         this.username = Preconditions.checkNotNull(username, "username is null");
         this.password = Preconditions.checkNotNull(password, "password is null");
         this.database = Preconditions.checkNotNull(database, "database is null");
-        this.primaryKey = primaryKey;
+        // the primaryKey must be "_id"
+        this.primaryKey = "_id";

Review Comment:
   `fields` should add "_id" field



-- 
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] [incubator-inlong] healchow commented on a diff in pull request #4666: [INLONG-4665][Sort] The primary key must be _id in mongoDB CDC Connector

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


##########
inlong-manager/manager-service/src/main/java/org/apache/inlong/manager/service/sort/util/ExtractNodeUtils.java:
##########
@@ -385,7 +385,6 @@ public static MongoExtractNode createExtractNode(MongoDBSource source) {
                 fieldInfos,
                 null,
                 properties,
-                source.getPrimaryKey(),

Review Comment:
   If the primary key cannot be changed, can we remove this field in the manager module?



-- 
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] [incubator-inlong] Oneal65 commented on a diff in pull request #4666: [INLONG-4665][Sort] The primary key must be _id in mongoDB CDC Connector

Posted by GitBox <gi...@apache.org>.
Oneal65 commented on code in PR #4666:
URL: https://github.com/apache/incubator-inlong/pull/4666#discussion_r896687001


##########
inlong-sort/sort-common/src/main/java/org/apache/inlong/sort/protocol/node/extract/MongoExtractNode.java:
##########
@@ -61,23 +61,23 @@ public class MongoExtractNode extends ExtractNode implements Serializable {
 
     @JsonCreator
     public MongoExtractNode(@JsonProperty("id") String id,
-        @JsonProperty("name") String name,
-        @JsonProperty("fields") List<FieldInfo> fields,
-        @Nullable @JsonProperty("watermarkField") WatermarkField waterMarkField,
-        @JsonProperty("properties") Map<String, String> properties,
-        @JsonProperty("primaryKey") String primaryKey,
-        @JsonProperty("collection") @Nonnull String collection,
-        @JsonProperty("hostname") String hostname,
-        @JsonProperty("username") String username,
-        @JsonProperty("password") String password,
-        @JsonProperty("database") String database) {
+            @JsonProperty("name") String name,
+            @JsonProperty("fields") List<FieldInfo> fields,
+            @Nullable @JsonProperty("watermarkField") WatermarkField waterMarkField,
+            @JsonProperty("properties") Map<String, String> properties,
+            @JsonProperty("collection") @Nonnull String collection,
+            @JsonProperty("hostname") String hostname,
+            @JsonProperty("username") String username,
+            @JsonProperty("password") String password,
+            @JsonProperty("database") String database) {
         super(id, name, fields, waterMarkField, properties);
         this.collection = Preconditions.checkNotNull(collection, "collection is null");
         this.hosts = Preconditions.checkNotNull(hostname, "hostname is null");
         this.username = Preconditions.checkNotNull(username, "username is null");
         this.password = Preconditions.checkNotNull(password, "password is null");
         this.database = Preconditions.checkNotNull(database, "database is null");
-        this.primaryKey = primaryKey;
+        // the primaryKey must be "_id"
+        this.primaryKey = "_id";

Review Comment:
   > `fields` should add "_id" field
   
   DONE



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