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 07:33:42 UTC

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

ruanwenjun commented on code in PR #1911:
URL: https://github.com/apache/incubator-seatunnel/pull/1911#discussion_r879111348


##########
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:
   It seems you don't need to add this method, the method defined at line 182 is used to get `ClickhouseTable`, in my view, you just need to change the `createTableDDL` in line 192.



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