JeremyXin commented on code in PR #9446:
URL: https://github.com/apache/seatunnel/pull/9446#discussion_r2163958294


##########
seatunnel-connectors-v2/connector-clickhouse/src/main/java/org/apache/seatunnel/connectors/seatunnel/clickhouse/config/ClickhouseSourceConfig.java:
##########
@@ -0,0 +1,99 @@
+/*
+ * 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.seatunnel.clickhouse.config;
+
+import 
org.apache.seatunnel.shade.com.fasterxml.jackson.annotation.JsonProperty;
+
+import org.apache.seatunnel.api.configuration.ReadonlyConfig;
+import 
org.apache.seatunnel.connectors.seatunnel.clickhouse.util.ClickhouseUtil;
+
+import org.apache.commons.lang3.StringUtils;
+
+import lombok.Builder;
+import lombok.Data;
+
+import java.io.Serializable;
+import java.util.List;
+import java.util.Map;
+
+@Data
+@Builder(builderClassName = "Builder")
+public class ClickhouseSourceConfig implements Serializable {
+
+    private static final long serialVersionUID = -5139627460951339176L;
+
+    private String host;
+    private String username;
+    private String password;
+
+    @JsonProperty("table_path")
+    private String tablePath;
+
+    @JsonProperty("filter_query")
+    private String filterQuery;
+
+    @JsonProperty("partition_list")
+    private List<String> partitionList;
+
+    @JsonProperty("batch_size")
+    private int batchSize;
+
+    @JsonProperty("part_size")
+    private int partSize;
+
+    private String sql;
+
+    private Map<String, String> clickhouseConfig;
+
+    @JsonProperty("server_time_zone")
+    private String serverTimeZone;
+
+    private boolean isSqlStrategyRead;
+
+    public static ClickhouseSourceConfig of(ReadonlyConfig config) {
+        if (!config.getOptional(ClickhouseBaseOptions.TABLE_PATH).isPresent()
+                && 
!config.getOptional(ClickhouseSourceOptions.SQL).isPresent()) {
+            throw new IllegalArgumentException(
+                    "`table_path` and `sql` parameter cannot be both empty.");
+        }
+
+        ClickhouseSourceConfig.Builder builder = 
ClickhouseSourceConfig.builder();
+        builder.host(config.get(ClickhouseBaseOptions.HOST));
+        builder.username(config.get(ClickhouseBaseOptions.USERNAME));
+        builder.password(config.get(ClickhouseBaseOptions.PASSWORD));
+        builder.tablePath(config.get(ClickhouseBaseOptions.TABLE_PATH));
+        
builder.filterQuery(config.get(ClickhouseSourceOptions.CLICKHOUSE_FILTER_QUERY));
+        
builder.partitionList(config.get(ClickhouseSourceOptions.CLICKHOUSE_PARTITION_LIST));
+        
builder.batchSize(config.get(ClickhouseSourceOptions.CLICKHOUSE_BATCH_SIZE));
+        
builder.partSize(config.get(ClickhouseSourceOptions.CLICKHOUSE_PART_SIZE));
+        builder.sql(config.get(ClickhouseSourceOptions.SQL));
+        
builder.clickhouseConfig(config.get(ClickhouseBaseOptions.CLICKHOUSE_CONFIG));
+        
builder.isSqlStrategyRead(config.getOptional(ClickhouseSourceOptions.SQL).isPresent());
+
+        return builder.build();
+    }
+
+    public String getTableIdentifier() {
+        if (StringUtils.isEmpty(tablePath)) {
+            // Extract table identifier from SQL
+            return ClickhouseUtil.extractTablePathFromSql(sql);
+        }
+
+        return tablePath;
+    }

Review Comment:
   The first question: For complex sql scenarios, user input sql will only be 
executed on a single shard, and no additional order by and limit operations 
will be performed, just like the query executed on ck server.
   
   The second question: I thought about it. There could be multiple 
possibilities in complex sql scenarios, such as users using group by, or 
multiple tables for global join, etc. Splitting sql in these scenarios might be 
rather complex, and no suitable solution has been thought of for the time being.
   
   Perhaps we can first execute the above-mentioned complex sql according to 
the single concurrent solution and then continue to try to optimize it later?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to