You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@seatunnel.apache.org by GitBox <gi...@apache.org> on 2023/01/07 01:59:27 UTC

[GitHub] [incubator-seatunnel] john8628 opened a new pull request, #3892: [Feature][connector][doris] Support write cdc changelog event in dori…

john8628 opened a new pull request, #3892:
URL: https://github.com/apache/incubator-seatunnel/pull/3892

   …s sink
   
   <!--
   
   Thank you for contributing to SeaTunnel! Please make sure that your code changes
   are covered with tests. And in case of new features or big changes
   remember to adjust the documentation.
   
   Feel free to ping committers for the review!
   
   ## Contribution Checklist
   
     - Make sure that the pull request corresponds to a [GITHUB issue](https://github.com/apache/incubator-seatunnel/issues).
   
     - Name the pull request in the form "[Feature] [component] Title of the pull request", where *Feature* can be replaced by `Hotfix`, `Bug`, etc.
   
     - Minor fixes should be named following this pattern: `[hotfix] [docs] Fix typo in README.md doc`.
   
   -->
   
   ## Purpose of this pull request
   
   <!-- Describe the purpose of this pull request. For example: This pull request adds checkstyle plugin.-->
   #3726 
   ## Check list
   
   * [ ] Code changed are covered with tests, or it does not need tests for reason:
   * [ ] If any new Jar binary package adding in your PR, please add License Notice according
     [New License Guide](https://github.com/apache/incubator-seatunnel/blob/dev/docs/en/contribution/new-license.md)
   * [ ] If necessary, please update the documentation to describe the new feature. https://github.com/apache/incubator-seatunnel/tree/dev/docs
   * [ ] If you are contributing the connector code, please check that the following files are updated:
     1. Update change log that in connector document. For more details you can refer to [connector-v2](https://github.com/apache/incubator-seatunnel/tree/dev/docs/en/connector-v2)
     2. Update [plugin-mapping.properties](https://github.com/apache/incubator-seatunnel/blob/dev/plugin-mapping.properties) and add new connector information in it
     3. Update the pom file of [seatunnel-dist](https://github.com/apache/incubator-seatunnel/blob/dev/seatunnel-dist/pom.xml)
   * [ ] Update the [`release-note`](https://github.com/apache/incubator-seatunnel/blob/dev/release-note.md).


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

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


[GitHub] [incubator-seatunnel] john8628 commented on a diff in pull request #3892: [Feature][CDC] Support write cdc changelog event in doris sink

Posted by GitBox <gi...@apache.org>.
john8628 commented on code in PR #3892:
URL: https://github.com/apache/incubator-seatunnel/pull/3892#discussion_r1064299945


##########
seatunnel-connectors-v2/connector-doris/src/main/java/org/apache/seatunnel/connectors/doris/serialize/DorisColumnRowSerialize.java:
##########
@@ -0,0 +1,103 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.seatunnel.connectors.doris.serialize;
+
+import org.apache.seatunnel.api.serialization.SerializationSchema;
+import org.apache.seatunnel.api.table.type.SeaTunnelRow;
+import org.apache.seatunnel.api.table.type.SeaTunnelRowType;
+import org.apache.seatunnel.common.exception.CommonErrorCode;
+import org.apache.seatunnel.connectors.doris.client.DorisRecord;
+import org.apache.seatunnel.connectors.doris.config.SinkConfig;
+import org.apache.seatunnel.connectors.doris.exception.DorisConnectorException;
+import org.apache.seatunnel.connectors.doris.util.DelimiterParserUtil;
+import org.apache.seatunnel.format.json.JsonSerializationSchema;
+import org.apache.seatunnel.format.text.TextSerializationSchema;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+import lombok.Getter;
+
+public class DorisColumnRowSerialize implements SeaTunnelRowSerializer{
+    /**
+     * RowType to generate the runtime converter.
+     */
+    private final SeaTunnelRowType rowType;
+    private final SinkConfig sinkConfig;
+
+    /** Object mapper that is used to create output JSON objects. */
+    @Getter
+    private final ObjectMapper mapper = new ObjectMapper();
+
+    public DorisColumnRowSerialize(SeaTunnelRowType rowType, SinkConfig sinkConfig) {
+        this.rowType = rowType;
+        this.sinkConfig = sinkConfig;
+    }
+
+    @Override
+    public DorisRecord serialize(SeaTunnelRow row) {
+        switch (row.getRowKind()) {
+            case INSERT:
+                return serializeInsert(row);
+            case UPDATE_AFTER:
+                return serializeUpsert(row);
+            case DELETE:
+                return serializeDelete(row);
+            default:
+                throw new DorisConnectorException(
+                    CommonErrorCode.UNSUPPORTED_OPERATION, "Unsupported write row kind: " + row.getRowKind());
+        }
+    }
+
+    private DorisRecord serializeDelete(SeaTunnelRow row) {
+        SerializationSchema serializer = createSerializer(sinkConfig, rowType);
+        String record = new String(serializer.serialize(row));
+        DorisRecord dorisRecord = DorisRecord.builder().record(record)
+            .enableDelete(true).mergeType("DELETE").build();
+        return dorisRecord;
+    }
+
+    private DorisRecord serializeUpsert(SeaTunnelRow row) {
+        SerializationSchema serializer = createSerializer(sinkConfig, rowType);

Review Comment:
   OK, that's 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@seatunnel.apache.org

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


[GitHub] [incubator-seatunnel] john8628 closed pull request #3892: [Feature][CDC] Support write cdc changelog event in doris sink

Posted by "john8628 (via GitHub)" <gi...@apache.org>.
john8628 closed pull request #3892: [Feature][CDC] Support write cdc changelog event in doris sink
URL: https://github.com/apache/incubator-seatunnel/pull/3892


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

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


[GitHub] [incubator-seatunnel] john8628 commented on pull request #3892: [Feature][CDC] Support write cdc changelog event in doris sink

Posted by "john8628 (via GitHub)" <gi...@apache.org>.
john8628 commented on PR #3892:
URL: https://github.com/apache/incubator-seatunnel/pull/3892#issuecomment-1408516651

   > 
   
   ok , thanks,i will work on it recently~


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

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


[GitHub] [incubator-seatunnel] hailin0 commented on pull request #3892: [Feature][CDC] Support write cdc changelog event in doris sink

Posted by "hailin0 (via GitHub)" <gi...@apache.org>.
hailin0 commented on PR #3892:
URL: https://github.com/apache/incubator-seatunnel/pull/3892#issuecomment-1407937802

   reference this pr add e2e
   @john8628 
   https://github.com/apache/incubator-seatunnel/pull/3865


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

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


[GitHub] [incubator-seatunnel] hailin0 commented on pull request #3892: [Feature][CDC] Support write cdc changelog event in doris sink

Posted by GitBox <gi...@apache.org>.
hailin0 commented on PR #3892:
URL: https://github.com/apache/incubator-seatunnel/pull/3892#issuecomment-1374398504

   waiting for this pr merged and add e2e testcase
   
   https://github.com/apache/incubator-seatunnel/pull/3865


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

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


[GitHub] [incubator-seatunnel] TaoZex commented on a diff in pull request #3892: [Feature][CDC] Support write cdc changelog event in doris sink

Posted by GitBox <gi...@apache.org>.
TaoZex commented on code in PR #3892:
URL: https://github.com/apache/incubator-seatunnel/pull/3892#discussion_r1063979253


##########
seatunnel-connectors-v2/connector-doris/src/main/java/org/apache/seatunnel/connectors/doris/serialize/DorisColumnRowSerialize.java:
##########
@@ -0,0 +1,103 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.seatunnel.connectors.doris.serialize;
+
+import org.apache.seatunnel.api.serialization.SerializationSchema;
+import org.apache.seatunnel.api.table.type.SeaTunnelRow;
+import org.apache.seatunnel.api.table.type.SeaTunnelRowType;
+import org.apache.seatunnel.common.exception.CommonErrorCode;
+import org.apache.seatunnel.connectors.doris.client.DorisRecord;
+import org.apache.seatunnel.connectors.doris.config.SinkConfig;
+import org.apache.seatunnel.connectors.doris.exception.DorisConnectorException;
+import org.apache.seatunnel.connectors.doris.util.DelimiterParserUtil;
+import org.apache.seatunnel.format.json.JsonSerializationSchema;
+import org.apache.seatunnel.format.text.TextSerializationSchema;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+import lombok.Getter;
+
+public class DorisColumnRowSerialize implements SeaTunnelRowSerializer{
+    /**
+     * RowType to generate the runtime converter.
+     */
+    private final SeaTunnelRowType rowType;
+    private final SinkConfig sinkConfig;
+
+    /** Object mapper that is used to create output JSON objects. */
+    @Getter
+    private final ObjectMapper mapper = new ObjectMapper();
+
+    public DorisColumnRowSerialize(SeaTunnelRowType rowType, SinkConfig sinkConfig) {
+        this.rowType = rowType;
+        this.sinkConfig = sinkConfig;
+    }
+
+    @Override
+    public DorisRecord serialize(SeaTunnelRow row) {
+        switch (row.getRowKind()) {
+            case INSERT:
+                return serializeInsert(row);
+            case UPDATE_AFTER:
+                return serializeUpsert(row);
+            case DELETE:
+                return serializeDelete(row);
+            default:
+                throw new DorisConnectorException(
+                    CommonErrorCode.UNSUPPORTED_OPERATION, "Unsupported write row kind: " + row.getRowKind());
+        }
+    }
+
+    private DorisRecord serializeDelete(SeaTunnelRow row) {
+        SerializationSchema serializer = createSerializer(sinkConfig, rowType);
+        String record = new String(serializer.serialize(row));
+        DorisRecord dorisRecord = DorisRecord.builder().record(record)
+            .enableDelete(true).mergeType("DELETE").build();
+        return dorisRecord;
+    }
+
+    private DorisRecord serializeUpsert(SeaTunnelRow row) {
+        SerializationSchema serializer = createSerializer(sinkConfig, rowType);

Review Comment:
   Calling the createSerializer method on each row may affect performance.
   How about calling the createSerializer method only once?



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

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


[GitHub] [incubator-seatunnel] hailin0 commented on pull request #3892: [Feature][CDC] Support write cdc changelog event in doris sink

Posted by GitBox <gi...@apache.org>.
hailin0 commented on PR #3892:
URL: https://github.com/apache/incubator-seatunnel/pull/3892#issuecomment-1379731257

   > waiting for this pr merged and add e2e testcase
   > 
   > #3865
   
   Please add e2e testcase
   


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

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