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 2024/08/30 03:31:14 UTC

[PR] [Feature][Clickhouse] Support multi-table source read [seatunnel]

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

   <!--
   
   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/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.-->
   
   
   ### Does this PR introduce _any_ user-facing change?
   
   <!--
   Note that it means *any* user-facing change including all aspects such as the documentation fix.
   If yes, please clarify the previous behavior and the change this PR proposes - provide the console output, description and/or an example to show the behavior difference if possible.
   If possible, please also clarify if this is a user-facing change compared to the released SeaTunnel versions or within the unreleased branches such as dev.
   If no, write 'No'.
   If you are adding/modifying connector documents, please follow our new specifications: https://github.com/apache/seatunnel/issues/4544.
   -->
   
   
   ### How was this patch tested?
   
   <!--
   If tests were added, say they were added here. Please make sure to add some test cases that check the changes thoroughly including negative and positive cases if possible.
   If it was tested in a way different from regular unit tests, please clarify how you tested step by step, ideally copy and paste-able, so that other reviewers can test and check, and descendants can verify in the future.
   If tests were not added, please describe why they were not added and/or why it was difficult to add.
   If you are adding E2E test cases, maybe refer to https://github.com/apache/seatunnel/blob/dev/seatunnel-e2e/seatunnel-connector-v2-e2e/connector-cdc-mysql-e2e/src/test/resources/mysqlcdc_to_mysql.conf, here is a good example.
   -->
   
   
   ### Check list
   
   * [ ] If any new Jar binary package adding in your PR, please add License Notice according
     [New License Guide](https://github.com/apache/seatunnel/blob/dev/docs/en/contribution/new-license.md)
   * [ ] If necessary, please update the documentation to describe the new feature. https://github.com/apache/seatunnel/tree/dev/docs
   * [ ] If you are contributing the connector code, please check that the following files are updated:
     1. Update [plugin-mapping.properties](https://github.com/apache/seatunnel/blob/dev/plugin-mapping.properties) and add new connector information in it
     2. Update the pom file of [seatunnel-dist](https://github.com/apache/seatunnel/blob/dev/seatunnel-dist/pom.xml)
     3. Add ci label in [label-scope-conf](https://github.com/apache/seatunnel/blob/dev/.github/workflows/labeler/label-scope-conf.yml)
     4. Add e2e testcase in [seatunnel-e2e](https://github.com/apache/seatunnel/tree/dev/seatunnel-e2e/seatunnel-connector-v2-e2e/)
     5. Update connector [plugin_config](https://github.com/apache/seatunnel/blob/dev/config/plugin_config)
   * [ ] Update the [`release-note`](https://github.com/apache/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


Re: [PR] [Feature][Clickhouse] Support multi-table source read [seatunnel]

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

   Please fix ci error


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


Re: [PR] [Feature][Clickhouse] Support multi-table source read [seatunnel]

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


##########
seatunnel-connectors-v2/connector-clickhouse/src/main/java/org/apache/seatunnel/connectors/seatunnel/clickhouse/source/ClickhouseSource.java:
##########
@@ -17,70 +17,217 @@
 
 package org.apache.seatunnel.connectors.seatunnel.clickhouse.source;
 
+import org.apache.seatunnel.shade.com.typesafe.config.Config;
+import org.apache.seatunnel.shade.com.typesafe.config.ConfigFactory;
+
+import org.apache.seatunnel.api.common.PrepareFailException;
+import org.apache.seatunnel.api.common.SeaTunnelAPIErrorCode;
+import org.apache.seatunnel.api.configuration.ReadonlyConfig;
 import org.apache.seatunnel.api.source.Boundedness;
 import org.apache.seatunnel.api.source.SeaTunnelSource;
 import org.apache.seatunnel.api.source.SourceReader;
 import org.apache.seatunnel.api.source.SourceSplitEnumerator;
 import org.apache.seatunnel.api.source.SupportColumnProjection;
 import org.apache.seatunnel.api.source.SupportParallelism;
 import org.apache.seatunnel.api.table.catalog.CatalogTable;
+import org.apache.seatunnel.api.table.catalog.CatalogTableUtil;
+import org.apache.seatunnel.api.table.catalog.PhysicalColumn;
+import org.apache.seatunnel.api.table.catalog.TableIdentifier;
+import org.apache.seatunnel.api.table.catalog.TablePath;
+import org.apache.seatunnel.api.table.catalog.TableSchema;
+import org.apache.seatunnel.api.table.type.SeaTunnelDataType;
 import org.apache.seatunnel.api.table.type.SeaTunnelRow;
+import org.apache.seatunnel.api.table.type.SeaTunnelRowType;
+import org.apache.seatunnel.common.config.CheckConfigUtil;
+import org.apache.seatunnel.common.constants.PluginType;
+import org.apache.seatunnel.common.utils.ExceptionUtils;
+import org.apache.seatunnel.connectors.seatunnel.clickhouse.config.ClickhouseCatalogConfig;
+import org.apache.seatunnel.connectors.seatunnel.clickhouse.exception.ClickhouseConnectorException;
 import org.apache.seatunnel.connectors.seatunnel.clickhouse.state.ClickhouseSourceState;
+import org.apache.seatunnel.connectors.seatunnel.clickhouse.util.ClickhouseUtil;
+import org.apache.seatunnel.connectors.seatunnel.clickhouse.util.TypeConvertUtil;
+
+import org.apache.commons.collections4.map.HashedMap;
 
+import com.clickhouse.client.ClickHouseClient;
+import com.clickhouse.client.ClickHouseException;
+import com.clickhouse.client.ClickHouseFormat;
 import com.clickhouse.client.ClickHouseNode;
+import com.clickhouse.client.ClickHouseResponse;
+import com.google.auto.service.AutoService;
 
 import java.util.Collections;
 import java.util.List;
+import java.util.Map;
+import java.util.concurrent.ThreadLocalRandom;
+import java.util.stream.Collectors;
+
+import static org.apache.seatunnel.connectors.seatunnel.clickhouse.config.ClickhouseConfig.CLICKHOUSE_CONFIG;
+import static org.apache.seatunnel.connectors.seatunnel.clickhouse.config.ClickhouseConfig.DATABASE;
+import static org.apache.seatunnel.connectors.seatunnel.clickhouse.config.ClickhouseConfig.HOST;
+import static org.apache.seatunnel.connectors.seatunnel.clickhouse.config.ClickhouseConfig.PASSWORD;
+import static org.apache.seatunnel.connectors.seatunnel.clickhouse.config.ClickhouseConfig.SERVER_TIME_ZONE;
+import static org.apache.seatunnel.connectors.seatunnel.clickhouse.config.ClickhouseConfig.SQL;
+import static org.apache.seatunnel.connectors.seatunnel.clickhouse.config.ClickhouseConfig.TABLE_LIST;
+import static org.apache.seatunnel.connectors.seatunnel.clickhouse.config.ClickhouseConfig.TABLE_PATH;
+import static org.apache.seatunnel.connectors.seatunnel.clickhouse.config.ClickhouseConfig.USERNAME;
 
+@AutoService(SeaTunnelSource.class)
 public class ClickhouseSource
         implements SeaTunnelSource<SeaTunnelRow, ClickhouseSourceSplit, ClickhouseSourceState>,
                 SupportParallelism,
                 SupportColumnProjection {
 
     private List<ClickHouseNode> servers;
-    private CatalogTable catalogTable;
-    private String sql;
+    private Map<TablePath, ClickhouseCatalogConfig> tableClickhouseCatalogConfigMap =
+            new HashedMap<>();
 
-    public ClickhouseSource(List<ClickHouseNode> servers, CatalogTable catalogTable, String sql) {
-        this.servers = servers;
-        this.catalogTable = catalogTable;
-        this.sql = sql;
-    }
+    private static final String defaultTablePath = "default";
 
     @Override
     public String getPluginName() {
         return "Clickhouse";
     }
 
+    @Override
+    public void prepare(Config config) throws PrepareFailException {
+        config =
+                config.withFallback(
+                        ConfigFactory.parseMap(
+                                Collections.singletonMap(
+                                        SERVER_TIME_ZONE.key(), SERVER_TIME_ZONE.defaultValue())));
+
+        Map<String, String> customConfig =
+                CheckConfigUtil.isValidParam(config, CLICKHOUSE_CONFIG.key())
+                        ? config.getObject(CLICKHOUSE_CONFIG.key()).entrySet().stream()
+                                .collect(
+                                        Collectors.toMap(
+                                                Map.Entry::getKey,
+                                                entry -> entry.getValue().unwrapped().toString()))
+                        : null;
+
+        servers =
+                ClickhouseUtil.createNodes(
+                        config.getString(HOST.key()),
+                        config.getString(DATABASE.key()),
+                        config.getString(SERVER_TIME_ZONE.key()),
+                        config.getString(USERNAME.key()),
+                        config.getString(PASSWORD.key()),
+                        customConfig);
+
+        ClickHouseNode currentServer =
+                servers.get(ThreadLocalRandom.current().nextInt(servers.size()));
+
+        ReadonlyConfig readonlyConfig = ReadonlyConfig.fromConfig(config);
+        String sql = readonlyConfig.getOptional(SQL).orElse(null);
+
+        if (readonlyConfig.getOptional(TABLE_LIST).isPresent()) {
+            readonlyConfig.get(TABLE_LIST).stream()
+                    .map(ReadonlyConfig::fromMap)
+                    .forEach(
+                            conf -> {
+                                String confSql = conf.getOptional(SQL).get();
+                                SeaTunnelRowType clickhouseRowType =
+                                        getClickhouseRowType(currentServer, confSql);
+                                TablePath tablePath =
+                                        TablePath.of(conf.getOptional(TABLE_PATH).orElse(""));
+                                CatalogTable catalogTable =
+                                        createCatalogTable(clickhouseRowType, tablePath);
+
+                                ClickhouseCatalogConfig clickhouseCatalogConfig =
+                                        new ClickhouseCatalogConfig();
+                                clickhouseCatalogConfig.setSql(confSql);
+                                clickhouseCatalogConfig.setCatalogTable(catalogTable);
+                                tableClickhouseCatalogConfigMap.put(
+                                        tablePath, clickhouseCatalogConfig);
+                            });
+        } else {
+            SeaTunnelRowType clickhouseRowType = getClickhouseRowType(currentServer, sql);
+            CatalogTable catalogTable =
+                    CatalogTableUtil.getCatalogTable(defaultTablePath, clickhouseRowType);
+
+            ClickhouseCatalogConfig clickhouseCatalogConfig = new ClickhouseCatalogConfig();
+            clickhouseCatalogConfig.setCatalogTable(catalogTable);
+            clickhouseCatalogConfig.setSql(sql);
+            tableClickhouseCatalogConfigMap.put(
+                    TablePath.of(defaultTablePath), clickhouseCatalogConfig);
+        }
+    }
+
+    private CatalogTable createCatalogTable(SeaTunnelRowType rowType, TablePath tablePath) {

Review Comment:
   ![image](https://github.com/user-attachments/assets/c08b1b68-6b86-44de-875b-0288ab778690)
   I think it's an outdated one. Is it okay to keep using 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-unsubscribe@seatunnel.apache.org

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


Re: [PR] [Feature][Clickhouse] Support multi-table source read [seatunnel]

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


##########
seatunnel-connectors-v2/connector-clickhouse/src/main/java/org/apache/seatunnel/connectors/seatunnel/clickhouse/source/ClickhouseSourceFactory.java:
##########
@@ -62,65 +39,11 @@ public String factoryIdentifier() {
         return "Clickhouse";
     }
 
-    @Override
-    public <T, SplitT extends SourceSplit, StateT extends Serializable>
-            TableSource<T, SplitT, StateT> createSource(TableSourceFactoryContext context) {

Review Comment:
    Do the conf parsing directly in ClickhouseSource.prepare to avoid unnecessary parameter passing
   



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


Re: [PR] [Feature][Clickhouse] Support multi-table source read [seatunnel]

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

   PTAL: @hailin0 @Hisoka-X 


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


Re: [PR] [Feature][Clickhouse] Support multi-table source read [seatunnel]

Posted by "hailin0 (via GitHub)" <gi...@apache.org>.
hailin0 commented on code in PR #7529:
URL: https://github.com/apache/seatunnel/pull/7529#discussion_r1850123590


##########
seatunnel-e2e/seatunnel-connector-v2-e2e/connector-clickhouse-e2e/src/test/java/org/apache/seatunnel/connectors/seatunnel/clickhouse/ClickhouseIT.java:
##########
@@ -107,6 +112,27 @@ public void testSourceParallelism(TestContainer container) throws Exception {
         Assertions.assertEquals(0, execResult.getExitCode());
     }
 
+    @TestTemplate
+    @DisabledOnContainer(
+            value = {},
+            type = {EngineType.SPARK, EngineType.FLINK},
+            disabledReason = "The multi-catalog does not currently support the Spark Flink engine")

Review Comment:
   Current, flink and spark supported multi-tables



##########
seatunnel-connectors-v2/connector-clickhouse/src/main/java/org/apache/seatunnel/connectors/seatunnel/clickhouse/source/ClickhouseSource.java:
##########
@@ -17,70 +17,217 @@
 
 package org.apache.seatunnel.connectors.seatunnel.clickhouse.source;
 
+import org.apache.seatunnel.shade.com.typesafe.config.Config;
+import org.apache.seatunnel.shade.com.typesafe.config.ConfigFactory;
+
+import org.apache.seatunnel.api.common.PrepareFailException;
+import org.apache.seatunnel.api.common.SeaTunnelAPIErrorCode;
+import org.apache.seatunnel.api.configuration.ReadonlyConfig;
 import org.apache.seatunnel.api.source.Boundedness;
 import org.apache.seatunnel.api.source.SeaTunnelSource;
 import org.apache.seatunnel.api.source.SourceReader;
 import org.apache.seatunnel.api.source.SourceSplitEnumerator;
 import org.apache.seatunnel.api.source.SupportColumnProjection;
 import org.apache.seatunnel.api.source.SupportParallelism;
 import org.apache.seatunnel.api.table.catalog.CatalogTable;
+import org.apache.seatunnel.api.table.catalog.CatalogTableUtil;
+import org.apache.seatunnel.api.table.catalog.PhysicalColumn;
+import org.apache.seatunnel.api.table.catalog.TableIdentifier;
+import org.apache.seatunnel.api.table.catalog.TablePath;
+import org.apache.seatunnel.api.table.catalog.TableSchema;
+import org.apache.seatunnel.api.table.type.SeaTunnelDataType;
 import org.apache.seatunnel.api.table.type.SeaTunnelRow;
+import org.apache.seatunnel.api.table.type.SeaTunnelRowType;
+import org.apache.seatunnel.common.config.CheckConfigUtil;
+import org.apache.seatunnel.common.constants.PluginType;
+import org.apache.seatunnel.common.utils.ExceptionUtils;
+import org.apache.seatunnel.connectors.seatunnel.clickhouse.config.ClickhouseCatalogConfig;
+import org.apache.seatunnel.connectors.seatunnel.clickhouse.exception.ClickhouseConnectorException;
 import org.apache.seatunnel.connectors.seatunnel.clickhouse.state.ClickhouseSourceState;
+import org.apache.seatunnel.connectors.seatunnel.clickhouse.util.ClickhouseUtil;
+import org.apache.seatunnel.connectors.seatunnel.clickhouse.util.TypeConvertUtil;
+
+import org.apache.commons.collections4.map.HashedMap;
 
+import com.clickhouse.client.ClickHouseClient;
+import com.clickhouse.client.ClickHouseException;
+import com.clickhouse.client.ClickHouseFormat;
 import com.clickhouse.client.ClickHouseNode;
+import com.clickhouse.client.ClickHouseResponse;
+import com.google.auto.service.AutoService;
 
 import java.util.Collections;
 import java.util.List;
+import java.util.Map;
+import java.util.concurrent.ThreadLocalRandom;
+import java.util.stream.Collectors;
+
+import static org.apache.seatunnel.connectors.seatunnel.clickhouse.config.ClickhouseConfig.CLICKHOUSE_CONFIG;
+import static org.apache.seatunnel.connectors.seatunnel.clickhouse.config.ClickhouseConfig.DATABASE;
+import static org.apache.seatunnel.connectors.seatunnel.clickhouse.config.ClickhouseConfig.HOST;
+import static org.apache.seatunnel.connectors.seatunnel.clickhouse.config.ClickhouseConfig.PASSWORD;
+import static org.apache.seatunnel.connectors.seatunnel.clickhouse.config.ClickhouseConfig.SERVER_TIME_ZONE;
+import static org.apache.seatunnel.connectors.seatunnel.clickhouse.config.ClickhouseConfig.SQL;
+import static org.apache.seatunnel.connectors.seatunnel.clickhouse.config.ClickhouseConfig.TABLE_LIST;
+import static org.apache.seatunnel.connectors.seatunnel.clickhouse.config.ClickhouseConfig.TABLE_PATH;
+import static org.apache.seatunnel.connectors.seatunnel.clickhouse.config.ClickhouseConfig.USERNAME;
 
+@AutoService(SeaTunnelSource.class)
 public class ClickhouseSource
         implements SeaTunnelSource<SeaTunnelRow, ClickhouseSourceSplit, ClickhouseSourceState>,
                 SupportParallelism,
                 SupportColumnProjection {
 
     private List<ClickHouseNode> servers;
-    private CatalogTable catalogTable;
-    private String sql;
+    private Map<TablePath, ClickhouseCatalogConfig> tableClickhouseCatalogConfigMap =
+            new HashedMap<>();
 
-    public ClickhouseSource(List<ClickHouseNode> servers, CatalogTable catalogTable, String sql) {
-        this.servers = servers;
-        this.catalogTable = catalogTable;
-        this.sql = sql;
-    }
+    private static final String defaultTablePath = "default";
 
     @Override
     public String getPluginName() {
         return "Clickhouse";
     }
 
+    @Override
+    public void prepare(Config config) throws PrepareFailException {
+        config =
+                config.withFallback(
+                        ConfigFactory.parseMap(
+                                Collections.singletonMap(
+                                        SERVER_TIME_ZONE.key(), SERVER_TIME_ZONE.defaultValue())));
+
+        Map<String, String> customConfig =
+                CheckConfigUtil.isValidParam(config, CLICKHOUSE_CONFIG.key())
+                        ? config.getObject(CLICKHOUSE_CONFIG.key()).entrySet().stream()
+                                .collect(
+                                        Collectors.toMap(
+                                                Map.Entry::getKey,
+                                                entry -> entry.getValue().unwrapped().toString()))
+                        : null;
+
+        servers =
+                ClickhouseUtil.createNodes(
+                        config.getString(HOST.key()),
+                        config.getString(DATABASE.key()),
+                        config.getString(SERVER_TIME_ZONE.key()),
+                        config.getString(USERNAME.key()),
+                        config.getString(PASSWORD.key()),
+                        customConfig);
+
+        ClickHouseNode currentServer =
+                servers.get(ThreadLocalRandom.current().nextInt(servers.size()));
+
+        ReadonlyConfig readonlyConfig = ReadonlyConfig.fromConfig(config);
+        String sql = readonlyConfig.getOptional(SQL).orElse(null);
+
+        if (readonlyConfig.getOptional(TABLE_LIST).isPresent()) {
+            readonlyConfig.get(TABLE_LIST).stream()
+                    .map(ReadonlyConfig::fromMap)
+                    .forEach(
+                            conf -> {
+                                String confSql = conf.getOptional(SQL).get();
+                                SeaTunnelRowType clickhouseRowType =
+                                        getClickhouseRowType(currentServer, confSql);
+                                TablePath tablePath =
+                                        TablePath.of(conf.getOptional(TABLE_PATH).orElse(""));
+                                CatalogTable catalogTable =
+                                        createCatalogTable(clickhouseRowType, tablePath);
+
+                                ClickhouseCatalogConfig clickhouseCatalogConfig =
+                                        new ClickhouseCatalogConfig();
+                                clickhouseCatalogConfig.setSql(confSql);
+                                clickhouseCatalogConfig.setCatalogTable(catalogTable);
+                                tableClickhouseCatalogConfigMap.put(
+                                        tablePath, clickhouseCatalogConfig);
+                            });
+        } else {
+            SeaTunnelRowType clickhouseRowType = getClickhouseRowType(currentServer, sql);
+            CatalogTable catalogTable =
+                    CatalogTableUtil.getCatalogTable(defaultTablePath, clickhouseRowType);
+
+            ClickhouseCatalogConfig clickhouseCatalogConfig = new ClickhouseCatalogConfig();
+            clickhouseCatalogConfig.setCatalogTable(catalogTable);
+            clickhouseCatalogConfig.setSql(sql);
+            tableClickhouseCatalogConfigMap.put(
+                    TablePath.of(defaultTablePath), clickhouseCatalogConfig);
+        }
+    }
+
+    private CatalogTable createCatalogTable(SeaTunnelRowType rowType, TablePath tablePath) {

Review Comment:
   why not use `CatalogTableUtil.convertDataTypeToCatalogTables()`



##########
seatunnel-e2e/seatunnel-connector-v2-e2e/connector-clickhouse-e2e/src/test/java/org/apache/seatunnel/connectors/seatunnel/clickhouse/ClickhouseIT.java:
##########
@@ -107,6 +112,27 @@ public void testSourceParallelism(TestContainer container) throws Exception {
         Assertions.assertEquals(0, execResult.getExitCode());
     }
 
+    @TestTemplate
+    @DisabledOnContainer(
+            value = {},
+            type = {EngineType.SPARK, EngineType.FLINK},
+            disabledReason = "The multi-catalog does not currently support the Spark Flink engine")
+    public void testClickhouseMultiSource(TestContainer container) throws Exception {
+        Container.ExecResult execResult = container.executeJob(CLICKHOUSE_MULTI_LIST_TABLE_CONFIG);
+        Assertions.assertEquals(0, execResult.getExitCode());
+
+        Thread.sleep(3000);

Review Comment:
   why sleep?



##########
seatunnel-connectors-v2/connector-clickhouse/src/main/java/org/apache/seatunnel/connectors/seatunnel/clickhouse/source/ClickhouseSource.java:
##########
@@ -17,70 +17,217 @@
 
 package org.apache.seatunnel.connectors.seatunnel.clickhouse.source;
 
+import org.apache.seatunnel.shade.com.typesafe.config.Config;
+import org.apache.seatunnel.shade.com.typesafe.config.ConfigFactory;
+
+import org.apache.seatunnel.api.common.PrepareFailException;
+import org.apache.seatunnel.api.common.SeaTunnelAPIErrorCode;
+import org.apache.seatunnel.api.configuration.ReadonlyConfig;
 import org.apache.seatunnel.api.source.Boundedness;
 import org.apache.seatunnel.api.source.SeaTunnelSource;
 import org.apache.seatunnel.api.source.SourceReader;
 import org.apache.seatunnel.api.source.SourceSplitEnumerator;
 import org.apache.seatunnel.api.source.SupportColumnProjection;
 import org.apache.seatunnel.api.source.SupportParallelism;
 import org.apache.seatunnel.api.table.catalog.CatalogTable;
+import org.apache.seatunnel.api.table.catalog.CatalogTableUtil;
+import org.apache.seatunnel.api.table.catalog.PhysicalColumn;
+import org.apache.seatunnel.api.table.catalog.TableIdentifier;
+import org.apache.seatunnel.api.table.catalog.TablePath;
+import org.apache.seatunnel.api.table.catalog.TableSchema;
+import org.apache.seatunnel.api.table.type.SeaTunnelDataType;
 import org.apache.seatunnel.api.table.type.SeaTunnelRow;
+import org.apache.seatunnel.api.table.type.SeaTunnelRowType;
+import org.apache.seatunnel.common.config.CheckConfigUtil;
+import org.apache.seatunnel.common.constants.PluginType;
+import org.apache.seatunnel.common.utils.ExceptionUtils;
+import org.apache.seatunnel.connectors.seatunnel.clickhouse.config.ClickhouseCatalogConfig;
+import org.apache.seatunnel.connectors.seatunnel.clickhouse.exception.ClickhouseConnectorException;
 import org.apache.seatunnel.connectors.seatunnel.clickhouse.state.ClickhouseSourceState;
+import org.apache.seatunnel.connectors.seatunnel.clickhouse.util.ClickhouseUtil;
+import org.apache.seatunnel.connectors.seatunnel.clickhouse.util.TypeConvertUtil;
+
+import org.apache.commons.collections4.map.HashedMap;
 
+import com.clickhouse.client.ClickHouseClient;
+import com.clickhouse.client.ClickHouseException;
+import com.clickhouse.client.ClickHouseFormat;
 import com.clickhouse.client.ClickHouseNode;
+import com.clickhouse.client.ClickHouseResponse;
+import com.google.auto.service.AutoService;
 
 import java.util.Collections;
 import java.util.List;
+import java.util.Map;
+import java.util.concurrent.ThreadLocalRandom;
+import java.util.stream.Collectors;
+
+import static org.apache.seatunnel.connectors.seatunnel.clickhouse.config.ClickhouseConfig.CLICKHOUSE_CONFIG;
+import static org.apache.seatunnel.connectors.seatunnel.clickhouse.config.ClickhouseConfig.DATABASE;
+import static org.apache.seatunnel.connectors.seatunnel.clickhouse.config.ClickhouseConfig.HOST;
+import static org.apache.seatunnel.connectors.seatunnel.clickhouse.config.ClickhouseConfig.PASSWORD;
+import static org.apache.seatunnel.connectors.seatunnel.clickhouse.config.ClickhouseConfig.SERVER_TIME_ZONE;
+import static org.apache.seatunnel.connectors.seatunnel.clickhouse.config.ClickhouseConfig.SQL;
+import static org.apache.seatunnel.connectors.seatunnel.clickhouse.config.ClickhouseConfig.TABLE_LIST;
+import static org.apache.seatunnel.connectors.seatunnel.clickhouse.config.ClickhouseConfig.TABLE_PATH;
+import static org.apache.seatunnel.connectors.seatunnel.clickhouse.config.ClickhouseConfig.USERNAME;
 
+@AutoService(SeaTunnelSource.class)
 public class ClickhouseSource
         implements SeaTunnelSource<SeaTunnelRow, ClickhouseSourceSplit, ClickhouseSourceState>,
                 SupportParallelism,
                 SupportColumnProjection {
 
     private List<ClickHouseNode> servers;
-    private CatalogTable catalogTable;
-    private String sql;
+    private Map<TablePath, ClickhouseCatalogConfig> tableClickhouseCatalogConfigMap =
+            new HashedMap<>();

Review Comment:
   why not use `HashMap`?



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


Re: [PR] [Feature][Clickhouse] Support multi-table source read [seatunnel]

Posted by "hailin0 (via GitHub)" <gi...@apache.org>.
hailin0 commented on code in PR #7529:
URL: https://github.com/apache/seatunnel/pull/7529#discussion_r1842279261


##########
docs/en/connector-v2/source/Clickhouse.md:
##########
@@ -95,6 +96,49 @@ sink {
 }
 ```
 
+### Multi Table read
+
+> This is a multi-table read case
+
+```bash
+
+
+env {
+  parallelism = 1
+  job.mode = "BATCH"
+}
+
+source {
+  Clickhouse {
+    host = "clickhouse:8123"
+    database = "default"
+    username = "default"
+    password = ""
+    table_list = [

Review Comment:
   add to `Source Options`



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


Re: [PR] [Feature][Clickhouse] Support multi-table source read [seatunnel]

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] closed pull request #7529: [Feature][Clickhouse] Support multi-table source read 
URL: https://github.com/apache/seatunnel/pull/7529


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


Re: [PR] [Feature][Clickhouse] Support multi-table source read [seatunnel]

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


##########
seatunnel-connectors-v2/connector-clickhouse/src/main/java/org/apache/seatunnel/connectors/seatunnel/clickhouse/source/ClickhouseSourceFactory.java:
##########
@@ -62,65 +39,11 @@ public String factoryIdentifier() {
         return "Clickhouse";
     }
 
-    @Override
-    public <T, SplitT extends SourceSplit, StateT extends Serializable>
-            TableSource<T, SplitT, StateT> createSource(TableSourceFactoryContext context) {

Review Comment:
   prepare already marked as deprecated.
   
   https://github.com/apache/seatunnel/blob/dev/seatunnel-api/src/main/java/org/apache/seatunnel/api/common/SeaTunnelPluginLifeCycle.java#L42



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


Re: [PR] [Feature][Clickhouse] Support multi-table source read [seatunnel]

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #7529:
URL: https://github.com/apache/seatunnel/pull/7529#issuecomment-3064431540

   This pull request has been automatically marked as stale because it has not had recent activity for 120 days. It will be closed in 7 days if no further activity occurs.


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


Re: [PR] [Feature][Clickhouse] Support multi-table source read [seatunnel]

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

   close #6230


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


Re: [PR] [Feature][Clickhouse] Support multi-table source read [seatunnel]

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


##########
docs/en/connector-v2/source/Clickhouse.md:
##########
@@ -1,3 +1,4 @@
+

Review Comment:
   ```suggestion
   ```



##########
docs/en/connector-v2/source/Clickhouse.md:
##########
@@ -95,6 +96,49 @@ sink {
 }
 ```
 
+### Multi Table read

Review Comment:
   Could you update zh doc too? Thanks.



##########
seatunnel-connectors-v2/connector-clickhouse/src/main/java/org/apache/seatunnel/connectors/seatunnel/clickhouse/source/ClickhouseSourceFactory.java:
##########
@@ -62,65 +39,11 @@ public String factoryIdentifier() {
         return "Clickhouse";
     }
 
-    @Override
-    public <T, SplitT extends SourceSplit, StateT extends Serializable>
-            TableSource<T, SplitT, StateT> createSource(TableSourceFactoryContext context) {

Review Comment:
   why?



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


Re: [PR] [Feature][Clickhouse] Support multi-table source read [seatunnel]

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #7529:
URL: https://github.com/apache/seatunnel/pull/7529#issuecomment-3092661905

   This pull request has been closed because it has not had recent activity. You could reopen it if you try to continue your work, and anyone who are interested in it are encouraged to continue work on this pull request.


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


Re: [PR] [Feature][Clickhouse] Support multi-table source read [seatunnel]

Posted by "zhilinli123 (via GitHub)" <gi...@apache.org>.
zhilinli123 closed pull request #7529: [Feature][Clickhouse] Support multi-table source read 
URL: https://github.com/apache/seatunnel/pull/7529


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