Z1Wu commented on code in PR #3416:
URL:
https://github.com/apache/incubator-seatunnel/pull/3416#discussion_r1022293438
##########
seatunnel-connectors-v2/connector-clickhouse/src/main/java/org/apache/seatunnel/connectors/seatunnel/clickhouse/sink/file/ClickhouseFileSinkWriter.java:
##########
@@ -164,17 +177,17 @@ private List<String>
generateClickhouseLocalFiles(List<SeaTunnelRow> rows) throw
command.add("\"" + "temp_table" + uuid + "\"");
command.add("-q");
command.add(String.format(
- "\"%s; INSERT INTO TABLE %s SELECT %s FROM temp_table%s;\"",
-
clickhouseTable.getCreateTableDDL().replace(clickhouseTable.getDatabase() +
".", "").replaceAll("`", ""),
- clickhouseTable.getLocalTableName(),
- readerOption.getTableSchema().keySet().stream().map(s -> {
- if (readerOption.getFields().contains(s)) {
- return s;
- } else {
- return "NULL";
- }
- }).collect(Collectors.joining(",")),
- uuid));
+ "\"%s; INSERT INTO TABLE %s SELECT %s FROM temp_table%s;\"",
+
clickhouseTable.getCreateTableDDL().replace(clickhouseTable.getDatabase() +
".", "").replaceAll("`", ""),
+ clickhouseTable.getLocalTableName(),
+ readerOption.getTableSchema().keySet().stream().map(s -> {
+ if (readerOption.getFields().contains(s)) {
+ return s;
+ } else {
+ return "NULL";
+ }
+ }).collect(Collectors.joining(",")),
+ uuid));
command.add("--path");
Review Comment:
`--path` is not available in early version of clickhouse. We can use
`--config-file` as a more genral option.
``` java
private static final String CK_LOCAL_CONFIG_TEMPLATE = "<yandex><path> %s
</path> <users><default><password/> <profile>default</profile>
<quota>default</quota><access_management>1</access_management></default></users><profiles><default/></profiles><quotas><default/></quotas></yandex>";
String ckLocalConfigPath = String.format("%s/%s/config.xml",
CLICKHOUSE_LOCAL_FILE_PREFIX, uuid);
try {
FileWriter myWriter = new FileWriter(ckLocalConfigPath);
myWriter.write(String.format(CK_LOCAL_CONFIG_TEMPLATE,
clickhouseLocalFile));
myWriter.close();
} catch (IOException e) {
throw new RuntimeException("Error occurs when create ck local
config", e);
}
command.add("--config-file");
command.add(ckLocalConfigPath);
```
--
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]