ClickHouse / ClickHouse/clickhouse-java

Example of migration from ClickHouseRowBinaryStream

Open
#2,239 6 comments 0 reactions 0 assignees View on GitHub
client-api-v2 enhancement question
Dominant language
Java
Stars
1.6k
Forks
636
Avg merge
2d 23h
Merged PRs (30d)
29

Description

### Use case
For users, migrating from old client

### Describe the solution you'd like
...

### Describe the alternatives you've considered
...

### Additional context
I have code, that insert `(UUID, UUID, UUID, byte[])` objects with `clickhouse-jdbc:0.3.1-patch`:
```java
@Override
protected ProcessorResult send(List events) throws BackendServiceFailedException {
var sentEvents = new LinkedList();
try (ClickHouseStatement statement = this.connection.createStatement()) {
statement.write().send(
"INSERT INTO tracing_spans_local (trace_id, parent_span_id, span_id, payload)",
stream -> {
for (var event : events) {
write(stream, sinkEvent.getInternalEvent())
}
},
ClickHouseFormat.RowBinary);

@Override
protected boolean write(ClickHouseRowBinaryStream stream, Event event) throws IOException {
// ...
stream.writeUUID(traceId.get());
stream.writeUUID(parentSpanId.orElse(DEFAULT_UUID));
stream.writeUUID(spanId.get());
stream.writeUnsignedLeb128(event.getBytes().length);
stream.writeBytes(event.getBytes());
```

Now I'm trying to updage to `client-v2:0.8.2` and have no idea how to rewrite this. Tried to use `RowBinaryFormatWriter`, but it looks very complex and have no docs. Probably, it's not for client use?

Contributor guide

Open the contributing guide

Research direction

Start by comparing the old ClickHouseRowBinaryStream usage with the client-v2 RowBinaryFormatWriter entry point and the JDBC client API mentioned in the issue. Document the equivalent migration for UUIDs, the length-prefixed payload, and byte data, with a complete example showing how the insert is sent.

Written by the indexing model from the issue text.

Assessment

Tech stack
clickhouse, java
Domain
api, documentation
Issue type
Documentation
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Needs clarification
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.