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
When serialize FixedString and string is bigger than size defined in Table definition #2223
clientModule: the client (client-v2; with legacy: the v1 client)data-typesArea: type names, value encoding and decoding, row mapping, data formatsenhancementv2-feedback
Effort to Fix: Small Type: Feature Request Affected Module: client-api-v2
Summary
When a Java string is serialized into a ClickHouse FixedString(N) column and its UTF-8 byte length exceeds N, the current code in BinaryStreamUtils.writeFixedString throws an exception via ClickHouseChecker.notLongerThan. The issue requests a configurable option (a flag or setting) to allow silent truncation to N bytes instead of throwing, with the important caveat that truncation must occur at a valid UTF-8 character boundary to avoid producing corrupted strings.
Should the truncation option be a global client setting (e.g., ClientConfigProperties) or a per-column/per-insert setting? A global flag makes it hard to tolerate oversized strings only for a subset of columns.
What is the preferred truncation semantics: truncate to at most N bytes at the last valid UTF-8 character boundary (safe, may lose more than one byte), or is padding with replacement characters acceptable?
Which client version is being used (client-v2 is assumed from existing labels)?
Tests to Add
Test 1: FixedString insertion — string exactly at byte limit
// Insert a FixedString(4) column with a 4-byte ASCII string — should succeedclient.insert("test_table", List.of(Map.of("col", "abcd")));
// assert row reads back as "abcd"
// Insert a FixedString(4) column with a 5-byte ASCII string — should throwassertThrows(ClientException.class, () ->
client.insert("test_table", List.of(Map.of("col", "abcde"))));
// "a☺c" is 5 bytes in UTF-8; FixedString(2) should truncate safely to "a" (1 byte),// not to "a\xe2" which is an invalid UTF-8 sequence.// (Enable truncation mode on the client/settings before inserting.)client.insert("test_table", List.of(Map.of("col", "a☺c")));
Stringresult = // read back the valueassertTrue(result.equals("a") || result.isEmpty()); // no garbled bytes
// FixedString(3) column with "abcde" — should truncate to "abc" without exception// (Enable truncation mode on the client/settings before inserting.)client.insert("test_table", List.of(Map.of("col", "abcde")));
Stringresult = // read back the valueassertEquals("abc", result);
Recommendation: Keep open — maintainer decision main already throws for a value longer than N bytes; it never truncates. The open item is whether to add a truncation option, with the scope and UTF-8 questions of the 2025-08 comment.
Category: Feature
Classification: impact: none · area: Data types & formats (FixedString)
Status on main: Not supported on main — on 8480ca001 with ClickHouse 26.11.4.11, RowBinaryFormatWriter rejects 'abcde' and 'a☺c' (5 bytes) for FixedString(3) with IllegalArgumentException, and a jdbc-v2 PreparedStatement gets the server error TOO_LARGE_STRING_SIZE. No option truncates.
Breaking change: No — can be done without a break, if the exception stays the default.
Duplicates / related: Related: [client-v2] FixedString padding #2929 — documents the current padding and the exception; its docs follow this decision.
Analysis: The client-v2 writers check the UTF-8 byte length and throw: BinaryStreamUtils.java:1617 for a String value (from SerializerUtils.java:726), and SerializerUtils.java:1134 for byte[]. Release v0.8.1 has the same check, so client-v2 does not send a shortened value as the issue says. jdbc-v2 writes ? values into the SQL text, so the server rejects the value on that path.
Automated triage by Polyglot AI. A maintainer makes the final decision.
clientModule: the client (client-v2; with legacy: the v1 client)data-typesArea: type names, value encoding and decoding, row mapping, data formatsenhancementv2-feedback
Activity
chernser commentedon Aug 12, 2025
@mzitnik
While working on this issue I've got next thoughts:
Here is the test for the last point:
Output:
The correct string should be a string with only
abecausee2is part of☺. In this case 3 bytes used for a character.chernser commentedon Jul 9, 2026
/triage
github-actions commentedon Jul 9, 2026
Triage Report
Effort to Fix: Small
Type: Feature Request
Affected Module: client-api-v2
Summary
When a Java string is serialized into a ClickHouse
FixedString(N)column and its UTF-8 byte length exceedsN, the current code inBinaryStreamUtils.writeFixedStringthrows an exception viaClickHouseChecker.notLongerThan. The issue requests a configurable option (a flag or setting) to allow silent truncation toNbytes instead of throwing, with the important caveat that truncation must occur at a valid UTF-8 character boundary to avoid producing corrupted strings.Recommended Labels & Priority
client-api-v2,v2-feedback,area:data-typeMissing Information / Questions for User
ClientConfigProperties) or a per-column/per-insert setting? A global flag makes it hard to tolerate oversized strings only for a subset of columns.Nbytes at the last valid UTF-8 character boundary (safe, may lose more than one byte), or is padding with replacement characters acceptable?Tests to Add
Test 1: FixedString insertion — string exactly at byte limit
Test 2: FixedString insertion — string exceeds limit, THROW mode (current default)
Test 3: FixedString insertion — UTF-8 multibyte string exceeds limit, TRUNCATE mode
Test 4: FixedString insertion — ASCII string exceeds limit, TRUNCATE mode
polyglotAI-bot commentedon Nov 28, 2026
Recommendation: Keep open — maintainer decision
mainalready throws for a value longer thanNbytes; it never truncates. The open item is whether to add a truncation option, with the scope and UTF-8 questions of the 2025-08 comment.main: Not supported on main — on8480ca001with ClickHouse 26.11.4.11,RowBinaryFormatWriterrejects'abcde'and'a☺c'(5 bytes) forFixedString(3)withIllegalArgumentException, and a jdbc-v2PreparedStatementgets the server errorTOO_LARGE_STRING_SIZE. No option truncates.Analysis: The client-v2 writers check the UTF-8 byte length and throw:
BinaryStreamUtils.java:1617for aStringvalue (fromSerializerUtils.java:726), andSerializerUtils.java:1134forbyte[]. Releasev0.8.1has the same check, so client-v2 does not send a shortened value as the issue says. jdbc-v2 writes?values into the SQL text, so the server rejects the value on that path.Automated triage by Polyglot AI. A maintainer makes the final decision.