Repository navigation
[tests] Core SQL test harness: write the zero bytes of a jdbc FixedString column - #3491
Open
polyglotAI-bot wants to merge 2 commits into
Open
polyglotAI-bot wants to merge 2 commits into
polyglotAI-bot wants to merge 2 commits into
Conversation
…ring column Since #3427, jdbc-v2 getObject gives the text of a FixedString(N) column without its trailing zero bytes (docs/features.md, "FixedString text reads"). The shim wrote the bytes of that String, so the jdbc backend lost the zero bytes that clickhouse-client writes: LiveTest failed for toFixedString('ab', 4), and 4 allowlisted upstream tests failed on jdbc. The renderer now adds zero bytes up to N to a String value of a top-level FixedString(N) column (also in Nullable, LowCardinality and SimpleAggregateFunction), in the escaped and the Raw formats. A FixedString value in a container or a Variant keeps its N bytes in jdbc-v2, so those values do not change, and a String member of a Variant gets no zero bytes. Fixes: #3488 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… jdbc backend only client-v2 gives all N bytes of a FixedString value, so the padding does nothing there today. With it, a client-v2 value without its zero bytes would show no diff. The jdbc Result now tells the renderer that the client trims FixedString text (Backend.Result.trimsFixedString), and the renderer gets N from the column type once. More cases: a value of exactly N bytes, LowCardinality(FixedString), SimpleAggregateFunction(any, Nullable(FixedString)), a Map of FixedString, the FixedString member of a Variant, and the client mode. README: also the trailing U+FFFD of jdbc-v2, and the values that keep their N bytes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
Auto-approved by the AI review gate on 1504146. Details in the approver's comment on this pull request.
AI review gate — auto-approved
History (latest 5 heads, newest first)
|
Client V2 CoverageCoverage Report
Class Coverage
|
JDBC V2 CoverageCoverage Report
Class Coverage
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #3488.
The scheduled
Upstream SQL testsworkflow is red onmainsince 2026-12-01 (run 46808949476):Build the shimfailsLiveTest.testRenderMatchesServer[jdbc, ... toFixedString('ab', 4) ...], so the upstream test jobs do not run.Cause: since #3427, jdbc-v2
getObjectgives the text of aFixedString(N)column without its trailing zero bytes (docs/features.md, "FixedStringtext reads"; intended). The shim'sjdbcbackend reads each value withgetObject, andTsvRendererwrote the bytes of thatString. The server (andclickhouse-client) writes all N bytes, so the shim wroteabwhere the server writesab\0\0. The workflow runs on a pull request only whentests/clickhouse-client/**changes, so #3427 did not show it.Fix (shim only, jdbc-v2 does not change): for the
jdbcbackend,TsvRenderer.render()adds zero bytes up to N to aStringvalue of a top-levelFixedString(N)column, also inNullable,LowCardinalityandSimpleAggregateFunction, in the escaped and theTSVRawformats. These are the column types that jdbc-v2 trims. The read method staysgetObject(harnessAGENTS.md, rule 3). Theclientbackend gets no padding: client-v2 gives all N bytes, and a client-v2 value without its zero bytes must still show as a diff.The padding is not in the shared
FixedStringbranch ofrenderValue. AFixedStringvalue in a container or aVariantkeeps its N bytes in jdbc-v2. The server sorts the members of aVariant(FixedString(4)beforeString), and the renderer writes aVariantvalue as the first member that accepts the Java value, so padding there would writeab\0\0for theStringmember'ab'ofVariant(String, FixedString(4), UInt8). The server writesab(new live test).Docs and other clients: the server default
output_format_trim_fixed_string = 0(26.10.4.207) is why the server writes the zero bytes; no setting of jdbc-v2 turns off its trimming (docs/features.md). The shims of clickhouse-go, clickhouse-js, clickhouse-cpp and clickhouse-cs write the bytes that their clients give, because those clients give all N bytes; only jdbc-v2 trims.Changes
Backend.Result.trimsFixedString()(defaultfalse;truefor thejdbcresult) andRunner: give the renderer the flag.TsvRenderer: gets N from the column type once (fixedStringLength), and pads inrender().TsvRendererTest: a@DataProviderfor thejdbcmode (padding by bytes foré, empty value, interior\0,NULL, the wrappers, a value of N bytes gets no more zero bytes, a value of more than N bytes is not cut), contrast rows (Array(FixedString), theStringmember of aVariant, aStringcolumn), theclientmode (no padding), and aTSVRawcase.LiveTest: new expressions on both backends:Nullable,LowCardinality,LowCardinality(Nullable),SimpleAggregateFunctionofFixedString, empty and multi-byte values,FixedStringinArray,TupleandMap, aVariantwith aStringmember and with aFixedStringmember, andFORMAT TSVRaw.README.md("Rendering"): the zero bytes, what cannot be restored, and the values that keep their N bytes (harnessAGENTS.md, rule 8).No
CHANGELOG.mdentry: test harness only, no change to a client.Test
CLICKHOUSE_CLIENT_CLI_LIVE=1 scripts/build.shon server 26.10.4.207:main27d63e9: 293 tests, 1 failure (the issue). With the new tests and without the fix: 310 tests, 10 failures (onjdbc, the case of the issue and 3 of the new live expressions; 6 renderer cases); the contrast cases and allclientcases pass. With the fix: 314 tests, 0 failures.jdbc, stock server 26.10.4.207,-j 6:02154_bit_slice_for_fixedstring,02474_extract_fixedstring_from_json,02981_translate_fixedstring,04037_cast_nullable_fixedstring_too_large(red onjdbcsince [jdbc-v2] Cut FixedString text after the last valid UTF-8 character in getString and getObject #3427) pass. The whole allowlist onjdbc(first commit; the second changes nothing forjdbc): 10,053 of 10,053 pass. With the final commit, the 450 allowlisted tests that useFixedString: all pass on both backends, except the 3 known failures that the allowlist marks for those backends.Checklist
🤖 Generated with Claude Code
Note
Low Risk
Changes are confined to the test harness under
tests/clickhouse-client; production jdbc-v2 and client-v2 behavior is untouched.Overview
Fixes upstream SQL test failures where the jdbc shim wrote shorter
FixedString(N)text than the server because jdbc-v2 returns those columns without trailing zero bytes.The shim exposes
Backend.Result#trimsFixedString()(true only for jdbc).Runnerpasses that intoTsvRenderer, which for top-levelFixedString(N)columns (includingNullable,LowCardinality, andSimpleAggregateFunction) pads UTF-8 byte length up to N in both escaped TSV and TSVRaw. Nested/containerFixedStringvalues and the client backend are unchanged.Adds
TsvRendererTestcoverage for padding edge cases,LiveTestexpressions for FixedString variants, and README rendering notes.Reviewed by Cursor Bugbot for commit 1504146. Bugbot is set up for automated code reviews on this repo. Configure here.