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
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);
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