Skip to content

feat(proto): support Variant type - #1183

Draft
nikandfor wants to merge 1 commit into
ClickHouse:mainfrom
nikandfor:Variant
Draft

feat(proto): support Variant type#1183
nikandfor wants to merge 1 commit into
ClickHouse:mainfrom
nikandfor:Variant

Conversation

@nikandfor

@nikandfor nikandfor commented Aug 1, 2026

Copy link
Copy Markdown
Contributor

Summary

Variant is the first head of the three-headed one (#939) — long wanted, never quite within reach.

It doesn't need to invent new mechanics, so I took the liberty (humbly) — it's built from the same blocks as Tuple, Map and LowCardinality: a state prefix, child columns, and the usual Encode/Decode/Prepare/Infer propagation.

Only basic access functions are implemented. That's the minimal basis — enough to read and write every value. Fancier helpers can land separately; a couple of ideas:

func AppendVariant[T any](c *ColVariant, d uint8, v T)
func VariantRow[T any](c *ColVariant, i int) (_ T, notNull bool)

Columns must be in ClickHouse order, i.e. sorted by type name, since discriminators are indices into that list. Prepare reports columns that are out of order or duplicated.

for changelog

Added support for the Variant data type via proto.ColVariant.

AI was used heavily — and I stand behind every line and symbol.

Checklist

Delete items not relevant to your PR:

  • Unit and integration tests covering the common scenarios were added
  • A human-readable description of the changes was provided to include in CHANGELOG

@nikandfor
nikandfor marked this pull request as draft August 3, 2026 09:06
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
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.

1 participant