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 2022/05/23 08:13:25 UTC

[GitHub] [incubator-seatunnel] Emor-nj commented on a diff in pull request #1911: [Feature] [spark-clickhouse||flink-clickhouse]ClickhouseFile support ReplicatedMergeTree

Emor-nj commented on code in PR #1911:
URL: https://github.com/apache/incubator-seatunnel/pull/1911#discussion_r879147091


##########
seatunnel-connectors/seatunnel-connectors-flink/seatunnel-connector-flink-clickhouse/src/main/java/org/apache/seatunnel/flink/clickhouse/sink/client/ClickhouseClient.java:
##########
@@ -212,4 +212,28 @@ public ClickhouseTable getClickhouseTable(String database, String table) {
 
     }
 
+    public String getLocalTableCreateDDL(String localDatabase, String localTable) {
+        try (ClickHouseConnection connection = balancedClickhouseDataSource.getConnection();
+             ClickHouseStatement statement = connection.createStatement()) {
+            String sql = String.format("select engine,create_table_query from system.tables where database = '%s' and name = '%s'", localDatabase, localTable);
+            ResultSet resultSet = statement.executeQuery(sql);
+            if (!resultSet.next()) {
+                throw new RuntimeException("Cannot get table from clickhouse, resultSet is empty");
+            }
+            String localEngine = resultSet.getString(1);
+            String createLocalTableDDL = resultSet.getString(2);
+            return localizationEngine(createLocalTableDDL, localEngine);
+        } catch (SQLException e) {
+            throw new RuntimeException("Cannot get clickhouse table", e);
+        }
+    }

Review Comment:
   Beacuse in line 107, if the parameter(config.getString(TABLE)) is DistributedTable, the createTableDDL(line 192 get)  will be the ddl for DistributedTable but not LocalTable. So i get the localDatabase and localTable from the variable ‘clickhouseTable’ which get in line 107, and use them to get LocalTableCreateDDL from getLocalTableCreateDDL.



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