Skip to content

fix(client-v2): write RowBinary Variant NULL values - #3402

Open
XSY-28 wants to merge 1 commit into
ClickHouse:mainfrom
XSY-28:fix/client-v2-variant-null-3400
Open

XSY-28 wants to merge 1 commit into
ClickHouse:mainfrom
XSY-28:fix/client-v2-variant-null-3400

Conversation

@XSY-28

@XSY-28 XSY-28 commented Nov 23, 2026 •

Copy link
Copy Markdown

Summary

Write the intrinsic 0xFF NULL discriminator for RowBinary Variant values, including values nested in containers. In RowBinaryWithDefaults, a null binding to a Variant column with an explicit default still selects that default. Non-null discriminators and the Dynamic encoding retain their existing paths.

Closes #3400.

Verification

  • The exact upstream package reads a server Variant NULL, then rejects writing it back in either RowBinary mode. The server independently emitted 11ff22 for a NULL Variant between UInt8 values. Its RowBinaryWithDefaults parser distinguished an explicit NULL from an omitted/defaulted value.
  • The client-v2 POJO regressions check the server-read NULL rebind, a mixed POJO batch, nested Array(Variant) values, non-null alternatives, explicit default and trailing fields over HTTP.
  • A clean all-in-one package passed two public API probes against the server. POJO inserts verified exact values in both formats, and the direct RowBinary writer verified NULL variants inside Tuple and Map with adjacent values intact.
  • Passed 823 codec/client unit tests and 68 Variant/Dynamic and POJO integration tests on ClickHouse 26.12.1.263 and Corretto JDK 17.0.21.1.

Checklist

AI assistance

OpenAI Codex (GPT-6.2 Sol, xhigh) authored the patch and ran the listed checks.


Note

Medium Risk
Changes RowBinary insert encoding for null Variant values; incorrect bytes could corrupt rows, but this aligns with the server wire format and is covered by new integration tests.

Overview
RowBinary inserts now emit 0xFF for a null Variant, including nested Array(Variant) elements, instead of rejecting the write or mis-encoding the stream.

writeValuePreamble treats Variant like Dynamic: a Java null on a non-nullable column is allowed through the preamble so serializerVariant can write the intrinsic null discriminator. RowBinaryWithDefaults behavior is unchanged—a null binding on a column with an explicit default still selects the default.

Adds a POJO integration test (plain RowBinary and defaults), updates features.md, and a changelog entry for #3400.

Reviewed by Cursor Bugbot for commit 0158c03. Bugbot is set up for automated code reviews on this repo. Configure here.

Write the Variant NULL discriminator in plain and defaults-aware RowBinary values, including nested variants. Preserve explicit column defaults and non-null alternative encoding.

Refs ClickHouse#3400
@XSY-28
XSY-28 requested review from a team and mzitnik as code owners November 23, 2026 18:43
@github-actions

Copy link
Copy Markdown

AI review gate — AI review gate could not decide

  • ai-gate: could not read the AI review — gh api repos/ClickHouse/clickhouse-java/commits/0158c034907eb37b7f16e365ce848f52ff4afc42/check-runs --paginate --slurp failed: unexpected end of JSON input

What to do:

  • This is a GitHub API or permissions problem, not your change. Re-run the gate; if it keeps failing, ask a repository administrator.

Re-run the gate with “Re-run jobs” after an approval or a finished review. A push re-runs it automatically.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[client-v2] Insert of a NULL value into a Variant column fails: the write path never emits the 0xFF NULL discriminator

1 participant