Repository navigation
Description
Description
In the core SQL test harness (tests/clickhouse-client), the shim writes some top-level string values with TabSeparated escapes when the output format is a Raw format (TSVRaw, TabSeparatedRaw, TSVRawWithNames, TabSeparatedRawWithNamesAndTypes). clickhouse-client and the server write these values without escapes. Affected:
SimpleAggregateFunction(f, T)whereTisString,FixedString,Nullable(String)orLowCardinality(String): both backends.Nullable(Enum8(...))andNullable(Enum16(...)): theclientbackend only (jdbcgets aStringand is correct).
String, Nullable(String), LowCardinality(Nullable(String)) and Enum8 are correct. The non-Raw formats are correct. No allowlisted upstream SQL test on 26.10 hits this today. A test that has such a value would fail through the shim, not because of the client.
Steps to reproduce
- Build the shim:
tests/clickhouse-client/scripts/build.sh -DskipTests. - Run the query of the code example through each backend and through the server.
- Compare the bytes.
Error Log or Exception StackTrace
SELECT CAST('a\tb' AS SimpleAggregateFunction(any, String)), CAST('a\'b' AS Nullable(Enum8('a\'b' = 1))) FORMAT TSVRaw
client:
a \ t b \t a \ ' b \n
jdbc:
a \ t b \t a ' b \n
server:
a \t b \t a ' b \n
Expected Behaviour
The shim writes the same bytes as the server: a real tab in the first value and a'b in the second. The TabSeparatedRaw docs say that it "differs from the TabSeparated format in that rows are written without escaping".
Root cause. TsvRenderer.render (tests/clickhouse-client/src/main/java/com/clickhouse/client/cli/TsvRenderer.java:81) writes raw bytes only when isStringType(type) is true. isStringType (:291-292) unwraps Nullable and LowCardinality, but not SimpleAggregateFunction. Also, the raw path gives the wrapper type to stringBytes (:82), and its Enum check t.base.startsWith("Enum") (:315) is false for Nullable(Enum8(...)). In both cases the value goes to renderValue, which escapes it.
The fix is in TsvRenderer only. Polyglot AI can open a fix PR if a maintainer assigns this issue to @polyglotAI-bot.
Related: #3348 (an Enum label with \t reads wrong in client-v2). The Enum case above uses ' to keep the two issues apart.
Code Example
cd tests/clickhouse-client
scripts/build.sh -DskipTests
q="SELECT CAST('a\tb' AS SimpleAggregateFunction(any, String)), CAST('a\\'b' AS Nullable(Enum8('a\\'b' = 1))) FORMAT TSVRaw"
for b in client jdbc; do
echo "$b:"; CLICKHOUSE_CLIENT_CLI_IMPL=$b bin/clickhouse-client --query "$q" | od -An -c
done
echo "server:"; curl -s --data-binary "$q" http://localhost:8123/ | od -An -cConfiguration
Client Configuration
Not applicable: the shim of the test harness, with its default settings.
Environment
- Cloud
- Client version:
mainat 27d63e9 (0.12.0-rc1-SNAPSHOT) - Language version: JDK 17.0.21.1, Maven 3.9.15
- OS: Linux (container)
ClickHouse Server
- ClickHouse Server version: 26.10.4.207 (the version in
tests/clickhouse-client/clickhouse-version) - ClickHouse Server non-default settings, if any: none
CREATE TABLEstatements for tables involved: none- Sample data for all these tables: none
Classification: impact: none · area: Docs & project (core SQL test harness, TabSeparatedRaw formats)
Found by automated analysis (Polyglot AI) while working on #3488. Verified against a live server.
Activity