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
Example of migration from ClickHouseRowBinaryStream #2239
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?
Yes, RowBinaryFormatWriter is still in development. But both documentation and examples are planned.
POJO fields are matched by names disregarding snake case (getFirstName() will work with first_name column). And there is com.clickhouse.client.api.Client.Builder#columnToMethodMatchingStrategy to set any custom matching strategy.
You may use TabSeparated format for the insert you have in the example. Look at recent benchmarks:
Looks good in case of balance of performance and ease of use. But I cant find configurations to override separators. With default \n and \t I will catch payload parse errors. This field contains something like this:
SELECT *
FROM tracing_spans_local
LIMIT 1
FORMAT Vertical
Query id: e7a3f713-8d10-4a09-a5af-ccb8cedabfe0
Row 1:
──────
date_hour: 0
trace_id: af209200-0000-0000-0e73-0018a6df0053
parent_span_id: 8f205a43-d77f-698a-e900-6015d9051b8b
span_id: 366f4cdb-09c9-6922-0040-69f663039169
payload: =���i3^�t�ᄊ��W�<traceId
��S� �spanId
ZC��i�s`���� beginTimestampUtc=���de|beginTimestampUtcOffset%M8
parentSpanId
1 row in set. Elapsed: 10.116 sec.
I see. Yes, binary format is better here.
Is payload encoded in some well know format? For example, if Avro https://clickhouse.com/docs/interfaces/formats/Avro it can be inserted into a table. But in this case schema should be more strict.
No. It is something like protobuf, but proprietary. It's easier to think of this field as just an array of bytes or string (field payload defined as String in destination CH table)
Yes, binary format is better here.
Do I understand correctly? Is RowBinaryFormatWriter a right class to use in my case?
UPD: It seems like I didn't change anything, but insert started working. Now I have this code:
In this configuration (without date_hour col, with ClickHouseFormat.RowBinaryWithDefaults for RowBinaryFormatWriter while ClickHouseFormat.RowBinary for .insert() call) inserts works. But data is spoiling. It feels like the data has "shifted":
Row 2:
──────
date_hour: 1085339904 -- 1.09 billion < got bytes from trace_id?
trace_id: 49004d67-df7f-f76e-c861-00b6fe60552d
parent_span_id: 00006783-ad83-5c22-0000-000000000000 < last bytes lost
span_id: 00000000-0000-0000-0000-000000000000
payload: =�_��ܿ��m01���N� traceId
If I use ClickHouseFormat.RowBinaryWithDefaults for both RowBinaryFormatWriter and .insert() call - I got error. If I use ClickHouseFormat.RowBinary and fill the date_hour col - I got the same error:
com.clickhouse.client.api.ServerException: Code: 33. DB::Exception: Cannot read all data. Bytes read: 2507. Bytes expected: 59727855.: (at row 3) : While executing BinaryRowInputFormat. (CANNOT_READ_ALL_DATA) (version 25.4.1.1604 (official build))
at com.clickhouse.client.api.internal.HttpAPIClientHelper.readError(HttpAPIClientHelper.java:384) ~[client-v2-0.8.2.jar:client-v2 0.8.2 (revision: 1414421)]
at com.clickhouse.client.api.internal.HttpAPIClientHelper.executeRequest(HttpAPIClientHelper.java:434) ~[client-v2-0.8.2.jar:client-v2 0.8.2 (revision: 1414421)]
at com.clickhouse.client.api.Client.lambda$insert$8(Client.java:1497) ~[client-v2-0.8.2.jar:client-v2 0.8.2 (revision: 1414421)]
at com.clickhouse.client.api.Client.runAsyncOperation(Client.java:2007) ~[client-v2-0.8.2.jar:client-v2 0.8.2 (revision: 1414421)]
at com.clickhouse.client.api.Client.insert(Client.java:1540) ~[client-v2-0.8.2.jar:client-v2 0.8.2 (revision: 1414421)]
at com.clickhouse.client.api.Client.insert(Client.java:1426) ~[client-v2-0.8.2.jar:client-v2 0.8.2 (revision: 1414421)]
at com.clickhouse.client.api.Client.insert(Client.java:1400) ~[client-v2-0.8.2.jar:client-v2 0.8.2 (revision: 1414421)]
at ru.kontur.vostok.hercules.traces.sink.exporter.TracesExporter.handle(TracesExporter.java:47) ~[classes/:na]
This issue has been automatically marked as stale because it has not had activity in the last year. It will be closed in 30 days if no further activity occurs. Please feel free to leave a comment if you believe the issue is still relevant. Thank you for your contributions!
Activity
makrushin-evgenii commentedon Mar 21, 2025
Now I have this code. Works strange:
RowBinarylogs " Insert succeed: 2000 rows written" when process batch of 100 eventsRowBinaryWithDefaultslog no errors when write no rows to tableMain questions:
UUIDandbyte[]toRowBinaryFormatWriter?TableSchema?Alternative question:
snake_case?Table
Code
Log (with
RowBinaryWithDefaults)Log (with
RowBinary)chernser commentedon Mar 22, 2025
Good day, @makrushin-evgenii !
Thank you for the question!
RowBinaryFormatWriteris still in development. But both documentation and examples are planned.getFirstName()will work withfirst_namecolumn). And there iscom.clickhouse.client.api.Client.Builder#columnToMethodMatchingStrategyto set any custom matching strategy.TabSeparatedformat for the insert you have in the example. Look at recent benchmarks: https://fastformats.clickhouse.com/makrushin-evgenii commentedon Mar 22, 2025
Thank you for answer
Looks good in case of balance of performance and ease of use. But I cant find configurations to override separators. With default
\nand\tI will catchpayloadparse errors. This field contains something like this:chernser commentedon Mar 25, 2025
I see. Yes, binary format is better here.
Is
payloadencoded in some well know format? For example, if Avro https://clickhouse.com/docs/interfaces/formats/Avro it can be inserted into a table. But in this case schema should be more strict.makrushin-evgenii commentedon Apr 2, 2025
No. It is something like protobuf, but proprietary. It's easier to think of this field as just an array of bytes or string (field
payloaddefined asStringin destination CH table)Do I understand correctly? Is
RowBinaryFormatWritera right class to use in my case?UPD: It seems like I didn't change anything, but insert started working. Now I have this code:
In this configuration (without
date_hourcol, withClickHouseFormat.RowBinaryWithDefaultsforRowBinaryFormatWriterwhileClickHouseFormat.RowBinaryfor.insert()call) inserts works. But data is spoiling. It feels like the data has "shifted":If I use
ClickHouseFormat.RowBinaryWithDefaultsfor bothRowBinaryFormatWriterand.insert()call - I got error. If I useClickHouseFormat.RowBinaryand fill thedate_hourcol - I got the same error:github-actions commentedon Apr 3, 2026
This issue has been automatically marked as stale because it has not had activity in the last year. It will be closed in 30 days if no further activity occurs. Please feel free to leave a comment if you believe the issue is still relevant. Thank you for your contributions!