Skip to content

[tests] clickhouse-client CLI shim: the Raw formats escape SimpleAggregateFunction(f, String) and Nullable(Enum) values #3490

Todo

Description

@polyglotAI-bot

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) where T is String, FixedString, Nullable(String) or LowCardinality(String): both backends.
  • Nullable(Enum8(...)) and Nullable(Enum16(...)): the client backend only (jdbc gets a String and 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

  1. Build the shim: tests/clickhouse-client/scripts/build.sh -DskipTests.
  2. Run the query of the code example through each backend and through the server.
  3. 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 -c

Configuration

Client Configuration

Not applicable: the shim of the test harness, with its default settings.

Environment

  • Cloud
  • Client version: main at 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 TABLE statements 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

  1. added
    tests
    on Dec 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

tests

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions