You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
How to insert Array(String) using clickhouse-http-client 4.6 (RowBinary) ? #1425
Hi @den-crane, you can use ClickHouseDataProcessor to find proper serializers for serialization, and use *Value object to set values. It's kind of tedius but here below is an example:
// table: (a String, b Nullable(String), c Array(String))try (ClickHousePipedOutputStreamstream = ClickHouseDataStreamFactory.getInstance()
.createPipedOutputStream(config, (Runnable) null)) {
// in async mode, which is default, execution happens in a worker threadfuture = request.data(stream.getInputStream()).execute();
List<ClickHouseColumn> columns = ClickHouseColumn
.parse("a String, b Nullable(String), c Array(String)");
ClickHouseDataProcessorprocessor = ClickHouseDataStreamFactory.getInstance().getProcessor(config, null,
stream, null, columns);
ClickHouseValue[] values = newClickHouseValue[] {
ClickHouseStringValue.ofNull(), // columns.get(0).newValue()ClickHouseStringValue.ofNull(), // columns.get(1).newValue()ClickHouseArrayValue.of(newString[0]) // columns.get(2).newValue()
};
ClickHouseSerializer[] serializers = processor.getSerializers(config, columns);
// writing happens in main threadfor (inti = 0; i < 10_000; i++) {
serializers[0].serialize(values[0].update(String.valueOf(i % 16)), stream);
serializers[1].serialize(values[1].update(UUID.randomUUID().toString()), stream);
serializers[2].serialize(values[2].update(newString[] { "1", "2" }), stream);
}
}
// response should be always closedtry (ClickHouseResponseresponse = future.get()) {
ClickHouseResponseSummarysummary = response.getSummary();
returnsummary.getWrittenRows();
}
Activity
zhicwu commentedon Aug 24, 2023
Hi @den-crane, you can use ClickHouseDataProcessor to find proper serializers for serialization, and use *Value object to set values. It's kind of tedius but here below is an example:
chernser commentedon Jan 9, 2025
need clear documentation