ruanwenjun commented on code in PR #1911:
URL:
https://github.com/apache/incubator-seatunnel/pull/1911#discussion_r879194714
##########
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:
If so, you can still change in `getClickhouseTable` method, since the method
`getLocalTableCreateDDL` you add will not check if the input table is
LocalTable or DistributedTable. I suggest you can just add query in
`getClickhouseTable` method.
--
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]