Emor-nj opened a new issue, #1848:
URL: https://github.com/apache/incubator-seatunnel/issues/1848

   ### Search before asking
   
   - [X] I had searched in the 
[issues](https://github.com/apache/incubator-seatunnel/issues?q=is%3Aissue+label%3A%22bug%22)
 and found no similar issues.
   
   
   ### What happened
   
   clickhouse-file 
sink这个新增特性中,在Table.initTableInfo中,会根据分布式表来获取本地表,然后根据本地表去拿到shard和本地表的建表语句。但是现有代码中仍然拿分布式表而不是获取的本地表去做以上的事情。
   ```
   def initTableInfo(hosts: List[HostAndPort], conn: ClickHouseConnectionImpl): 
Unit = {
       if (shards.size() == 0) {
         if (distributedEngine.equals(this.engine)) {
   //  这里的localTable实际是分布式表
           val localTable = getClickHouseDistributedTable(conn, database, name)
   //     这里的this.localTable是根据上一行的分布式表获取的本地表
           this.localTable = localTable.table
   //     这里去获取shard的时候,应该用本地表(this.localTable),而不是分布式表(localTable)
           val shardList = getClusterShardList(conn, localTable.clusterName, 
localTable.database, hosts)
           var weight = 0
           for (elem <- shardList) {
             this.shards.put(weight, elem)
             weight += elem.shardWeight
           }
           this.shardWeightCount = weight
   //     同理,这里去获取建表语句的时候,应该用本地表(this.localTable),而不是分布式表(localTable)
           this.localCreateTableDDL = getClickhouseTableInfo(conn, 
localTable.database, localTable.table)._2.createTableDDL
         } else {
           this.shards.put(0, Shard(1, 1, 1, hosts.head.host, hosts.head.host, 
hosts.head.port, database))
         }
       }
     }
   ```
   所以是否可以将 val localTable = getClickHouseDistributedTable(conn, database, 
name)改为val distributeTable = getClickHouseDistributedTable(conn, database, 
name)。  
   然后将获取shardList和localCreateTableDDL 时传入的localTable改为distributeTable 
   
   ### SeaTunnel Version
   
   dev
   
   ### SeaTunnel Config
   
   ```conf
   nothing
   ```
   
   
   ### Running Command
   
   ```shell
   nothing
   ```
   
   
   ### Error Exception
   
   ```log
   nothing
   ```
   
   
   ### Flink or Spark Version
   
   _No response_
   
   ### Java or Scala Version
   
   _No response_
   
   ### Screenshots
   
   _No response_
   
   ### Are you willing to submit PR?
   
   - [X] Yes I am willing to submit a PR!
   
   ### Code of Conduct
   
   - [X] I agree to follow this project's [Code of 
Conduct](https://www.apache.org/foundation/policies/conduct)
   


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