clickhouse-java
clickhouse-java copied to clipboard
Param 'format_csv_null_representation' did not work when export data to csv file
Describe the bug
When I use clickhouse java client to do some export work, I noticed that some column's value was null, but export to csv with value '\N'. I check the docs[https://clickhouse.com/docs/en/operations/settings/formats#format_csv_null_representation], and use it in my code, and the csv file still show the '\N' but 'NA'
Steps to reproduce
- Invoke the 'ClickHouseClient.dump()' method
2.Query result from sql console
【email Nullable(String)】
3.Export to csv file, and view it
Expected behaviour
when email's value is null, export 'NA' but default value '\N'
Code example
public static void exportDataToCsvFile(String tableOrQuery, String filePath) throws ExecutionException, InterruptedException {
ClickHouseClient
.dump(readServer, tableOrQuery, ClickHouseFormat.CSVWithNames, ClickHouseCompression.fromFileName(filePath), filePath)
.get();
}
/**
* add custom settings: format_csv_null_representation
*/
private static ClickHouseNode createReadServer() {
return ClickHouseNode.builder(commonServer)
.addOption(ClickHouseClientOption.CUSTOM_SETTINGS.getKey(), "format_csv_null_representation=NA")
.build();
}
Error log
Configuration
Environment
- Client version: 0.4.0
- Language version: jdk8
ClickHouse server
- ClickHouse Server version: 23.6.1.1524