You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@seatunnel.apache.org by "zhilinli123 (via GitHub)" <gi...@apache.org> on 2023/03/10 13:16:38 UTC

[GitHub] [incubator-seatunnel] zhilinli123 opened a new pull request, #4328: [Feature][Connector-V2][Clickhouse] Clickhouse supports spaced write and is relatively real-time data source friendly

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

   <!--
   
   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.-->
   
   ## 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] zhilinli123 closed pull request #4328: [Feature][Connector-V2][Clickhouse] Clickhouse supports spaced write and is relatively real-time data source friendly

Posted by "zhilinli123 (via GitHub)" <gi...@apache.org>.
zhilinli123 closed pull request #4328: [Feature][Connector-V2][Clickhouse] Clickhouse supports spaced write and is relatively real-time data source friendly
URL: https://github.com/apache/incubator-seatunnel/pull/4328


-- 
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 #4328: [Feature][Connector-V2][Clickhouse] Clickhouse supports spaced write and is relatively real-time data source friendly

Posted by "TaoZex (via GitHub)" <gi...@apache.org>.
TaoZex commented on code in PR #4328:
URL: https://github.com/apache/incubator-seatunnel/pull/4328#discussion_r1133676156


##########
seatunnel-e2e/seatunnel-connector-v2-e2e/connector-clickhouse-e2e/src/test/resources/clickhouse_to_interval_clickhouse.conf:
##########
@@ -0,0 +1,54 @@
+#
+# 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.
+#
+######
+###### This config file is a demonstration of streaming processing in seatunnel config
+######
+
+env {
+  # You can set spark configuration here
+  execution.parallelism = 1
+  job.mode = "BATCH"
+}
+
+source {
+  # This is a example source plugin **only for test and demonstrate the feature source plugin**
+ Clickhouse {
+     host = "clickhouse:8123"
+     database = "default"
+     sql = "select * from source_table"
+     username = "default"
+     password = ""
+     result_table_name = "source_table"
+    }
+  # If you would like to get more information about how to configure seatunnel and see full list of source plugins,
+  # please go to https://seatunnel.apache.org/docs/connector-v2/source/ClickhouseSource
+}
+
+sink {
+  Clickhouse {
+    host = "clickhouse:8123"
+    database = "default"
+    table = "sink_table"
+    username = "default"
+    password = ""
+    batch_interval_ms = "6000"
+

Review Comment:
   The line 49 is blank.



##########
seatunnel-e2e/seatunnel-connector-v2-e2e/connector-clickhouse-e2e/src/test/resources/clickhouse_to_interval_clickhouse.conf:
##########
@@ -0,0 +1,54 @@
+#
+# 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.
+#
+######
+###### This config file is a demonstration of streaming processing in seatunnel config
+######
+
+env {
+  # You can set spark configuration here
+  execution.parallelism = 1
+  job.mode = "BATCH"
+}
+
+source {
+  # This is a example source plugin **only for test and demonstrate the feature source plugin**
+ Clickhouse {
+     host = "clickhouse:8123"
+     database = "default"
+     sql = "select * from source_table"
+     username = "default"
+     password = ""
+     result_table_name = "source_table"
+    }
+  # If you would like to get more information about how to configure seatunnel and see full list of source plugins,
+  # please go to https://seatunnel.apache.org/docs/connector-v2/source/ClickhouseSource
+}
+
+sink {
+  Clickhouse {
+    host = "clickhouse:8123"
+    database = "default"
+    table = "sink_table"
+    username = "default"
+    password = ""
+    batch_interval_ms = "6000"
+

Review Comment:
   The line 49 is blank.



-- 
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] TyrantLucifer commented on pull request #4328: [Feature][Connector-V2][Clickhouse] Clickhouse supports spaced write and is relatively real-time data source friendly

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

   same as #4349


-- 
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] zhilinli123 closed pull request #4328: [Feature][Connector-V2][Clickhouse] Clickhouse supports spaced write and is relatively real-time data source friendly

Posted by "zhilinli123 (via GitHub)" <gi...@apache.org>.
zhilinli123 closed pull request #4328: [Feature][Connector-V2][Clickhouse] Clickhouse supports spaced write and is relatively real-time data source friendly
URL: https://github.com/apache/incubator-seatunnel/pull/4328


-- 
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] TyrantLucifer closed pull request #4328: [Feature][Connector-V2][Clickhouse] Clickhouse supports spaced write and is relatively real-time data source friendly

Posted by "TyrantLucifer (via GitHub)" <gi...@apache.org>.
TyrantLucifer closed pull request #4328: [Feature][Connector-V2][Clickhouse] Clickhouse supports spaced write and is relatively real-time data source friendly
URL: https://github.com/apache/incubator-seatunnel/pull/4328


-- 
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] zhilinli123 closed pull request #4328: [Feature][Connector-V2][Clickhouse] Clickhouse supports spaced write and is relatively real-time data source friendly

Posted by "zhilinli123 (via GitHub)" <gi...@apache.org>.
zhilinli123 closed pull request #4328: [Feature][Connector-V2][Clickhouse] Clickhouse supports spaced write and is relatively real-time data source friendly
URL: https://github.com/apache/incubator-seatunnel/pull/4328


-- 
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] zhilinli123 commented on a diff in pull request #4328: [Feature][Connector-V2][Clickhouse] Clickhouse supports spaced write and is relatively real-time data source friendly

Posted by "zhilinli123 (via GitHub)" <gi...@apache.org>.
zhilinli123 commented on code in PR #4328:
URL: https://github.com/apache/incubator-seatunnel/pull/4328#discussion_r1133663324


##########
seatunnel-e2e/seatunnel-connector-v2-e2e/connector-clickhouse-e2e/src/test/resources/clickhouse_to_interval_clickhouse.conf:
##########
@@ -0,0 +1,54 @@
+#
+# 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.
+#
+######
+###### This config file is a demonstration of streaming processing in seatunnel config
+######
+
+env {
+  # You can set spark configuration here
+  execution.parallelism = 1
+  job.mode = "BATCH"
+}
+
+source {
+  # This is a example source plugin **only for test and demonstrate the feature source plugin**
+ Clickhouse {
+     host = "clickhouse:8123"
+     database = "default"
+     sql = "select * from source_table"
+     username = "default"
+     password = ""
+     result_table_name = "source_table"
+    }
+  # If you would like to get more information about how to configure seatunnel and see full list of source plugins,
+  # please go to https://seatunnel.apache.org/docs/connector-v2/source/ClickhouseSource
+}
+
+sink {
+  Clickhouse {
+    host = "clickhouse:8123"
+    database = "default"
+    table = "sink_table"
+    username = "default"
+    password = ""
+    batch_interval_ms = "6000"
+

Review Comment:
   > Remove this line.
   batch_interval_ms?You mean using the default?
   
   



-- 
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] Hisoka-X commented on a diff in pull request #4328: [Feature][Connector-V2][Clickhouse] Clickhouse supports spaced write and is relatively real-time data source friendly

Posted by "Hisoka-X (via GitHub)" <gi...@apache.org>.
Hisoka-X commented on code in PR #4328:
URL: https://github.com/apache/incubator-seatunnel/pull/4328#discussion_r1136478422


##########
seatunnel-connectors-v2/connector-clickhouse/src/main/java/org/apache/seatunnel/connectors/seatunnel/clickhouse/sink/client/ClickhouseSinkWriter.java:
##########
@@ -75,16 +87,17 @@ public void write(SeaTunnelRow element) throws IOException {
                             .indexOf(this.option.getShardMetadata().getShardKey());
             shardKey = element.getField(i);
         }
-        ClickhouseBatchStatement statement = statementMap.get(shardRouter.getShard(shardKey));
-        JdbcBatchStatementExecutor clickHouseStatement = statement.getJdbcBatchStatementExecutor();
-        IntHolder sizeHolder = statement.getIntHolder();
+        this.statement = statementMap.get(shardRouter.getShard(shardKey));
+        this.clickHouseStatement = statement.getJdbcBatchStatementExecutor();
+        this.sizeHolder = statement.getIntHolder();

Review Comment:
   I mean one writer may have many `sizeHolder`, `clickHouseStatement` and `statement`. Because one writer have many shard, one shard have one `sizeHolder`, `clickHouseStatement` and `statement`. So the `this.sizeHolder` will change when last row had change ( the row change then the last shard also change).



-- 
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] zhilinli123 commented on a diff in pull request #4328: [Feature][Connector-V2][Clickhouse] Clickhouse supports spaced write and is relatively real-time data source friendly

Posted by "zhilinli123 (via GitHub)" <gi...@apache.org>.
zhilinli123 commented on code in PR #4328:
URL: https://github.com/apache/incubator-seatunnel/pull/4328#discussion_r1136503509


##########
seatunnel-connectors-v2/connector-clickhouse/src/main/java/org/apache/seatunnel/connectors/seatunnel/clickhouse/sink/client/ClickhouseSinkWriter.java:
##########
@@ -75,16 +87,17 @@ public void write(SeaTunnelRow element) throws IOException {
                             .indexOf(this.option.getShardMetadata().getShardKey());
             shardKey = element.getField(i);
         }
-        ClickhouseBatchStatement statement = statementMap.get(shardRouter.getShard(shardKey));
-        JdbcBatchStatementExecutor clickHouseStatement = statement.getJdbcBatchStatementExecutor();
-        IntHolder sizeHolder = statement.getIntHolder();
+        this.statement = statementMap.get(shardRouter.getShard(shardKey));
+        this.clickHouseStatement = statement.getJdbcBatchStatementExecutor();
+        this.sizeHolder = statement.getIntHolder();

Review Comment:
   Thank you for your explanation. I think I understand
   



-- 
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] zhilinli123 commented on a diff in pull request #4328: [Feature][Connector-V2][Clickhouse] Clickhouse supports spaced write and is relatively real-time data source friendly

Posted by "zhilinli123 (via GitHub)" <gi...@apache.org>.
zhilinli123 commented on code in PR #4328:
URL: https://github.com/apache/incubator-seatunnel/pull/4328#discussion_r1133464250


##########
seatunnel-connectors-v2/connector-clickhouse/src/main/java/org/apache/seatunnel/connectors/seatunnel/clickhouse/sink/client/ClickhouseSinkWriter.java:
##########
@@ -75,16 +87,17 @@ public void write(SeaTunnelRow element) throws IOException {
                             .indexOf(this.option.getShardMetadata().getShardKey());
             shardKey = element.getField(i);
         }
-        ClickhouseBatchStatement statement = statementMap.get(shardRouter.getShard(shardKey));
-        JdbcBatchStatementExecutor clickHouseStatement = statement.getJdbcBatchStatementExecutor();
-        IntHolder sizeHolder = statement.getIntHolder();
+        this.statement = statementMap.get(shardRouter.getShard(shardKey));
+        this.clickHouseStatement = statement.getJdbcBatchStatementExecutor();
+        this.sizeHolder = statement.getIntHolder();

Review Comment:
   ![image](https://user-images.githubusercontent.com/76689593/224617682-17b2078e-7efe-4af6-aab8-a8f5ae6bdba8.png)
   



-- 
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] Hisoka-X commented on a diff in pull request #4328: [Feature][Connector-V2][Clickhouse] Clickhouse supports spaced write and is relatively real-time data source friendly

Posted by "Hisoka-X (via GitHub)" <gi...@apache.org>.
Hisoka-X commented on code in PR #4328:
URL: https://github.com/apache/incubator-seatunnel/pull/4328#discussion_r1133468125


##########
seatunnel-connectors-v2/connector-clickhouse/src/main/java/org/apache/seatunnel/connectors/seatunnel/clickhouse/sink/client/ClickhouseSinkWriter.java:
##########
@@ -75,16 +87,17 @@ public void write(SeaTunnelRow element) throws IOException {
                             .indexOf(this.option.getShardMetadata().getShardKey());
             shardKey = element.getField(i);
         }
-        ClickhouseBatchStatement statement = statementMap.get(shardRouter.getShard(shardKey));
-        JdbcBatchStatementExecutor clickHouseStatement = statement.getJdbcBatchStatementExecutor();
-        IntHolder sizeHolder = statement.getIntHolder();
+        this.statement = statementMap.get(shardRouter.getShard(shardKey));
+        this.clickHouseStatement = statement.getJdbcBatchStatementExecutor();
+        this.sizeHolder = statement.getIntHolder();

Review Comment:
   > Should it be? `statement = statementMap.get(shardRouter.getShard(shardKey));
   > 
   > clickHouseStatement = statement.getJdbcBatchStatementExecutor();
   > 
   > sizeHolder = statement.getIntHolder(); `
   
   No, just do not use `ClickhouseSinkWriter` object's fields to save `statement` and  `sizeHolder`. Because it belong shard, not writer. One writer may have many shard.



-- 
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 #4328: [Feature][Connector-V2][Clickhouse] Clickhouse supports spaced write and is relatively real-time data source friendly

Posted by "TaoZex (via GitHub)" <gi...@apache.org>.
TaoZex commented on code in PR #4328:
URL: https://github.com/apache/incubator-seatunnel/pull/4328#discussion_r1133642022


##########
seatunnel-e2e/seatunnel-connector-v2-e2e/connector-clickhouse-e2e/src/test/resources/clickhouse_to_interval_clickhouse.conf:
##########
@@ -0,0 +1,54 @@
+#
+# 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.
+#
+######
+###### This config file is a demonstration of streaming processing in seatunnel config
+######
+
+env {
+  # You can set spark configuration here
+  execution.parallelism = 1
+  job.mode = "BATCH"
+}
+
+source {
+  # This is a example source plugin **only for test and demonstrate the feature source plugin**
+ Clickhouse {
+     host = "clickhouse:8123"
+     database = "default"
+     sql = "select * from source_table"
+     username = "default"
+     password = ""
+     result_table_name = "source_table"
+    }
+  # If you would like to get more information about how to configure seatunnel and see full list of source plugins,
+  # please go to https://seatunnel.apache.org/docs/connector-v2/source/ClickhouseSource
+}
+
+sink {
+  Clickhouse {
+    host = "clickhouse:8123"
+    database = "default"
+    table = "sink_table"
+    username = "default"
+    password = ""
+    batch_interval_ms = "6000"
+

Review Comment:
   Remove this line.



-- 
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] zhilinli123 closed pull request #4328: [Feature][Connector-V2][Clickhouse] Clickhouse supports spaced write and is relatively real-time data source friendly

Posted by "zhilinli123 (via GitHub)" <gi...@apache.org>.
zhilinli123 closed pull request #4328: [Feature][Connector-V2][Clickhouse] Clickhouse supports spaced write and is relatively real-time data source friendly
URL: https://github.com/apache/incubator-seatunnel/pull/4328


-- 
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] Hisoka-X commented on a diff in pull request #4328: [Feature][Connector-V2][Clickhouse] Clickhouse supports spaced write and is relatively real-time data source friendly

Posted by "Hisoka-X (via GitHub)" <gi...@apache.org>.
Hisoka-X commented on code in PR #4328:
URL: https://github.com/apache/incubator-seatunnel/pull/4328#discussion_r1133420674


##########
seatunnel-connectors-v2/connector-clickhouse/src/main/java/org/apache/seatunnel/connectors/seatunnel/clickhouse/sink/client/ClickhouseSinkWriter.java:
##########
@@ -75,16 +87,17 @@ public void write(SeaTunnelRow element) throws IOException {
                             .indexOf(this.option.getShardMetadata().getShardKey());
             shardKey = element.getField(i);
         }
-        ClickhouseBatchStatement statement = statementMap.get(shardRouter.getShard(shardKey));
-        JdbcBatchStatementExecutor clickHouseStatement = statement.getJdbcBatchStatementExecutor();
-        IntHolder sizeHolder = statement.getIntHolder();
+        this.statement = statementMap.get(shardRouter.getShard(shardKey));
+        this.clickHouseStatement = statement.getJdbcBatchStatementExecutor();
+        this.sizeHolder = statement.getIntHolder();

Review Comment:
   Don't use `this` to save fields which mapping with shardKey, because one writer can hold many different shardKey, so it will have many `statement`,`sizeHolder`. Use `this` to save it may cause conflusion.



-- 
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] Hisoka-X commented on a diff in pull request #4328: [Feature][Connector-V2][Clickhouse] Clickhouse supports spaced write and is relatively real-time data source friendly

Posted by "Hisoka-X (via GitHub)" <gi...@apache.org>.
Hisoka-X commented on code in PR #4328:
URL: https://github.com/apache/incubator-seatunnel/pull/4328#discussion_r1136468950


##########
seatunnel-connectors-v2/connector-clickhouse/src/main/java/org/apache/seatunnel/connectors/seatunnel/clickhouse/sink/client/ClickhouseSinkWriter.java:
##########
@@ -54,6 +59,13 @@
     private final ShardRouter shardRouter;
     private final transient ClickhouseProxy proxy;
     private final Map<Shard, ClickhouseBatchStatement> statementMap;
+    private transient ScheduledExecutorService scheduler;
+    private transient ScheduledFuture<?> scheduledFuture;
+    private transient JdbcBatchStatementExecutor clickHouseStatement;
+    private transient ClickhouseBatchStatement statement;
+    private transient IntHolder sizeHolder;
+    // Whether pre-initialization is required
+    private transient boolean isOpen;

Review Comment:
   This field is not necessary



##########
seatunnel-connectors-v2/connector-clickhouse/src/main/java/org/apache/seatunnel/connectors/seatunnel/clickhouse/sink/client/ClickhouseSinkWriter.java:
##########
@@ -75,16 +87,17 @@ public void write(SeaTunnelRow element) throws IOException {
                             .indexOf(this.option.getShardMetadata().getShardKey());
             shardKey = element.getField(i);
         }
-        ClickhouseBatchStatement statement = statementMap.get(shardRouter.getShard(shardKey));
-        JdbcBatchStatementExecutor clickHouseStatement = statement.getJdbcBatchStatementExecutor();
-        IntHolder sizeHolder = statement.getIntHolder();
+        this.statement = statementMap.get(shardRouter.getShard(shardKey));
+        this.clickHouseStatement = statement.getJdbcBatchStatementExecutor();
+        this.sizeHolder = statement.getIntHolder();
         // add into batch
-        addIntoBatch(element, clickHouseStatement);
-        sizeHolder.setValue(sizeHolder.getValue() + 1);
+        addIntoBatch(element, this.clickHouseStatement);
+        this.sizeHolder.setValue(this.sizeHolder.getValue() + 1);
+        tryOpen();

Review Comment:
   Move it into constructer



-- 
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] zhilinli123 closed pull request #4328: [Feature][Connector-V2][Clickhouse] Clickhouse supports spaced write and is relatively real-time data source friendly

Posted by "zhilinli123 (via GitHub)" <gi...@apache.org>.
zhilinli123 closed pull request #4328: [Feature][Connector-V2][Clickhouse] Clickhouse supports spaced write and is relatively real-time data source friendly
URL: https://github.com/apache/incubator-seatunnel/pull/4328


-- 
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] zhilinli123 closed pull request #4328: [Feature][Connector-V2][Clickhouse] Clickhouse supports spaced write and is relatively real-time data source friendly

Posted by "zhilinli123 (via GitHub)" <gi...@apache.org>.
zhilinli123 closed pull request #4328: [Feature][Connector-V2][Clickhouse] Clickhouse supports spaced write and is relatively real-time data source friendly
URL: https://github.com/apache/incubator-seatunnel/pull/4328


-- 
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] zhilinli123 commented on a diff in pull request #4328: [Feature][Connector-V2][Clickhouse] Clickhouse supports spaced write and is relatively real-time data source friendly

Posted by "zhilinli123 (via GitHub)" <gi...@apache.org>.
zhilinli123 commented on code in PR #4328:
URL: https://github.com/apache/incubator-seatunnel/pull/4328#discussion_r1133476180


##########
seatunnel-connectors-v2/connector-clickhouse/src/main/java/org/apache/seatunnel/connectors/seatunnel/clickhouse/sink/client/ClickhouseSinkWriter.java:
##########
@@ -75,16 +87,17 @@ public void write(SeaTunnelRow element) throws IOException {
                             .indexOf(this.option.getShardMetadata().getShardKey());
             shardKey = element.getField(i);
         }
-        ClickhouseBatchStatement statement = statementMap.get(shardRouter.getShard(shardKey));
-        JdbcBatchStatementExecutor clickHouseStatement = statement.getJdbcBatchStatementExecutor();
-        IntHolder sizeHolder = statement.getIntHolder();
+        this.statement = statementMap.get(shardRouter.getShard(shardKey));
+        this.clickHouseStatement = statement.getJdbcBatchStatementExecutor();
+        this.sizeHolder = statement.getIntHolder();

Review Comment:
   
   ![image](https://user-images.githubusercontent.com/76689593/224625878-005e86ab-a6c5-4613-9bfe-fc73c5d5619a.png)
   
   **statement** and **sizeHolder**   Create internal objects?



-- 
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] zhilinli123 commented on a diff in pull request #4328: [Feature][Connector-V2][Clickhouse] Clickhouse supports spaced write and is relatively real-time data source friendly

Posted by "zhilinli123 (via GitHub)" <gi...@apache.org>.
zhilinli123 commented on code in PR #4328:
URL: https://github.com/apache/incubator-seatunnel/pull/4328#discussion_r1133476180


##########
seatunnel-connectors-v2/connector-clickhouse/src/main/java/org/apache/seatunnel/connectors/seatunnel/clickhouse/sink/client/ClickhouseSinkWriter.java:
##########
@@ -75,16 +87,17 @@ public void write(SeaTunnelRow element) throws IOException {
                             .indexOf(this.option.getShardMetadata().getShardKey());
             shardKey = element.getField(i);
         }
-        ClickhouseBatchStatement statement = statementMap.get(shardRouter.getShard(shardKey));
-        JdbcBatchStatementExecutor clickHouseStatement = statement.getJdbcBatchStatementExecutor();
-        IntHolder sizeHolder = statement.getIntHolder();
+        this.statement = statementMap.get(shardRouter.getShard(shardKey));
+        this.clickHouseStatement = statement.getJdbcBatchStatementExecutor();
+        this.sizeHolder = statement.getIntHolder();

Review Comment:
    
   ![image](https://user-images.githubusercontent.com/76689593/224621028-1cf36942-7947-4b57-9692-e71bc34f484f.png)
   **statement** and **sizeHolder**   Create internal objects?



-- 
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] zhilinli123 commented on a diff in pull request #4328: [Feature][Connector-V2][Clickhouse] Clickhouse supports spaced write and is relatively real-time data source friendly

Posted by "zhilinli123 (via GitHub)" <gi...@apache.org>.
zhilinli123 commented on code in PR #4328:
URL: https://github.com/apache/incubator-seatunnel/pull/4328#discussion_r1133435146


##########
seatunnel-connectors-v2/connector-clickhouse/src/main/java/org/apache/seatunnel/connectors/seatunnel/clickhouse/sink/client/ClickhouseSinkWriter.java:
##########
@@ -75,16 +87,17 @@ public void write(SeaTunnelRow element) throws IOException {
                             .indexOf(this.option.getShardMetadata().getShardKey());
             shardKey = element.getField(i);
         }
-        ClickhouseBatchStatement statement = statementMap.get(shardRouter.getShard(shardKey));
-        JdbcBatchStatementExecutor clickHouseStatement = statement.getJdbcBatchStatementExecutor();
-        IntHolder sizeHolder = statement.getIntHolder();
+        this.statement = statementMap.get(shardRouter.getShard(shardKey));
+        this.clickHouseStatement = statement.getJdbcBatchStatementExecutor();
+        this.sizeHolder = statement.getIntHolder();

Review Comment:
   Should it be?
   `statement = statementMap.get(shardRouter.getShard(shardKey));
   
   clickHouseStatement = statement.getJdbcBatchStatementExecutor();
   
   sizeHolder = statement.getIntHolder();
   `



-- 
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] zhilinli123 commented on a diff in pull request #4328: [Feature][Connector-V2][Clickhouse] Clickhouse supports spaced write and is relatively real-time data source friendly

Posted by "zhilinli123 (via GitHub)" <gi...@apache.org>.
zhilinli123 commented on code in PR #4328:
URL: https://github.com/apache/incubator-seatunnel/pull/4328#discussion_r1133435146


##########
seatunnel-connectors-v2/connector-clickhouse/src/main/java/org/apache/seatunnel/connectors/seatunnel/clickhouse/sink/client/ClickhouseSinkWriter.java:
##########
@@ -75,16 +87,17 @@ public void write(SeaTunnelRow element) throws IOException {
                             .indexOf(this.option.getShardMetadata().getShardKey());
             shardKey = element.getField(i);
         }
-        ClickhouseBatchStatement statement = statementMap.get(shardRouter.getShard(shardKey));
-        JdbcBatchStatementExecutor clickHouseStatement = statement.getJdbcBatchStatementExecutor();
-        IntHolder sizeHolder = statement.getIntHolder();
+        this.statement = statementMap.get(shardRouter.getShard(shardKey));
+        this.clickHouseStatement = statement.getJdbcBatchStatementExecutor();
+        this.sizeHolder = statement.getIntHolder();

Review Comment:
   Should it be?
   `statement = statementMap.get(shardRouter.getShard(shardKey));
   clickHouseStatement = statement.getJdbcBatchStatementExecutor();
   sizeHolder = statement.getIntHolder();
   `



-- 
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] zhilinli123 commented on a diff in pull request #4328: [Feature][Connector-V2][Clickhouse] Clickhouse supports spaced write and is relatively real-time data source friendly

Posted by "zhilinli123 (via GitHub)" <gi...@apache.org>.
zhilinli123 commented on code in PR #4328:
URL: https://github.com/apache/incubator-seatunnel/pull/4328#discussion_r1136491404


##########
seatunnel-connectors-v2/connector-clickhouse/src/main/java/org/apache/seatunnel/connectors/seatunnel/clickhouse/sink/client/ClickhouseSinkWriter.java:
##########
@@ -54,6 +59,13 @@
     private final ShardRouter shardRouter;
     private final transient ClickhouseProxy proxy;
     private final Map<Shard, ClickhouseBatchStatement> statementMap;
+    private transient ScheduledExecutorService scheduler;
+    private transient ScheduledFuture<?> scheduledFuture;
+    private transient JdbcBatchStatementExecutor clickHouseStatement;
+    private transient ClickhouseBatchStatement statement;
+    private transient IntHolder sizeHolder;
+    // Whether pre-initialization is required
+    private transient boolean isOpen;

Review Comment:
   Can the boss point out the number of rows
   



##########
seatunnel-connectors-v2/connector-clickhouse/src/main/java/org/apache/seatunnel/connectors/seatunnel/clickhouse/sink/client/ClickhouseSinkWriter.java:
##########
@@ -54,6 +59,13 @@
     private final ShardRouter shardRouter;
     private final transient ClickhouseProxy proxy;
     private final Map<Shard, ClickhouseBatchStatement> statementMap;
+    private transient ScheduledExecutorService scheduler;
+    private transient ScheduledFuture<?> scheduledFuture;
+    private transient JdbcBatchStatementExecutor clickHouseStatement;
+    private transient ClickhouseBatchStatement statement;
+    private transient IntHolder sizeHolder;
+    // Whether pre-initialization is required
+    private transient boolean isOpen;

Review Comment:
   This is a historical commentary Please check the latest
   



-- 
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] zhilinli123 commented on a diff in pull request #4328: [Feature][Connector-V2][Clickhouse] Clickhouse supports spaced write and is relatively real-time data source friendly

Posted by "zhilinli123 (via GitHub)" <gi...@apache.org>.
zhilinli123 commented on code in PR #4328:
URL: https://github.com/apache/incubator-seatunnel/pull/4328#discussion_r1136493648


##########
seatunnel-connectors-v2/connector-clickhouse/src/main/java/org/apache/seatunnel/connectors/seatunnel/clickhouse/sink/client/ClickhouseSinkWriter.java:
##########
@@ -75,16 +87,17 @@ public void write(SeaTunnelRow element) throws IOException {
                             .indexOf(this.option.getShardMetadata().getShardKey());
             shardKey = element.getField(i);
         }
-        ClickhouseBatchStatement statement = statementMap.get(shardRouter.getShard(shardKey));
-        JdbcBatchStatementExecutor clickHouseStatement = statement.getJdbcBatchStatementExecutor();
-        IntHolder sizeHolder = statement.getIntHolder();
+        this.statement = statementMap.get(shardRouter.getShard(shardKey));
+        this.clickHouseStatement = statement.getJdbcBatchStatementExecutor();
+        this.sizeHolder = statement.getIntHolder();
         // add into batch
-        addIntoBatch(element, clickHouseStatement);
-        sizeHolder.setValue(sizeHolder.getValue() + 1);
+        addIntoBatch(element, this.clickHouseStatement);
+        this.sizeHolder.setValue(this.sizeHolder.getValue() + 1);
+        tryOpen();

Review Comment:
   This is a historical commentary Please check the latest



-- 
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] zhilinli123 commented on a diff in pull request #4328: [Feature][Connector-V2][Clickhouse] Clickhouse supports spaced write and is relatively real-time data source friendly

Posted by "zhilinli123 (via GitHub)" <gi...@apache.org>.
zhilinli123 commented on code in PR #4328:
URL: https://github.com/apache/incubator-seatunnel/pull/4328#discussion_r1133471205


##########
seatunnel-connectors-v2/connector-clickhouse/src/main/java/org/apache/seatunnel/connectors/seatunnel/clickhouse/sink/client/ClickhouseSinkWriter.java:
##########
@@ -75,16 +87,17 @@ public void write(SeaTunnelRow element) throws IOException {
                             .indexOf(this.option.getShardMetadata().getShardKey());
             shardKey = element.getField(i);
         }
-        ClickhouseBatchStatement statement = statementMap.get(shardRouter.getShard(shardKey));
-        JdbcBatchStatementExecutor clickHouseStatement = statement.getJdbcBatchStatementExecutor();
-        IntHolder sizeHolder = statement.getIntHolder();
+        this.statement = statementMap.get(shardRouter.getShard(shardKey));
+        this.clickHouseStatement = statement.getJdbcBatchStatementExecutor();
+        this.sizeHolder = statement.getIntHolder();

Review Comment:
   ****
   
   > > Should it be? `statement = statementMap.get(shardRouter.getShard(shardKey));
   > > clickHouseStatement = statement.getJdbcBatchStatementExecutor();
   > > sizeHolder = statement.getIntHolder(); `
   > 
   > No, just do not use `ClickhouseSinkWriter` object's fields to save `statement` and `sizeHolder`. Because it belong shard, not writer. One writer may have many shard.
   
   Can you do some hints on code?
   



-- 
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] zhilinli123 commented on a diff in pull request #4328: [Feature][Connector-V2][Clickhouse] Clickhouse supports spaced write and is relatively real-time data source friendly

Posted by "zhilinli123 (via GitHub)" <gi...@apache.org>.
zhilinli123 commented on code in PR #4328:
URL: https://github.com/apache/incubator-seatunnel/pull/4328#discussion_r1133472466


##########
seatunnel-connectors-v2/connector-clickhouse/src/main/java/org/apache/seatunnel/connectors/seatunnel/clickhouse/sink/client/ClickhouseSinkWriter.java:
##########
@@ -75,16 +87,17 @@ public void write(SeaTunnelRow element) throws IOException {
                             .indexOf(this.option.getShardMetadata().getShardKey());
             shardKey = element.getField(i);
         }
-        ClickhouseBatchStatement statement = statementMap.get(shardRouter.getShard(shardKey));
-        JdbcBatchStatementExecutor clickHouseStatement = statement.getJdbcBatchStatementExecutor();
-        IntHolder sizeHolder = statement.getIntHolder();
+        this.statement = statementMap.get(shardRouter.getShard(shardKey));
+        this.clickHouseStatement = statement.getJdbcBatchStatementExecutor();
+        this.sizeHolder = statement.getIntHolder();

Review Comment:
   ![Uploading image.png…]()
   
   



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