Skip to content

[client-v2] Parse Enum type names that leave out the values - #3366

Closed
Indian-boult wants to merge 2 commits into
ClickHouse:mainfrom
Indian-boult:fix/enum-implicit-values
Closed

Indian-boult wants to merge 2 commits into
ClickHouse:mainfrom
Indian-boult:fix/enum-implicit-values

Conversation

@Indian-boult

@Indian-boult Indian-boult commented Nov 17, 2026 •

Copy link
Copy Markdown

Summary

ClickHouseEnum read each entry by splitting on the last = and required a value. The server allows entries without a value and numbers them itself, so Enum8('a', 'b') failed in the client with Invalid enum entry: 'a'. A name with = inside, like 'x=y', was split in the wrong place.

The parser now reads the quoted name first and then an optional value. Entries without a value get numbers the same way as autoAssignNumberForEnum on the server. The base is the value of the first entry, or 1 when it has none, and each entry adds its position. A list where only some entries after the first one have a value still throws, because the server rejects it too. I checked every case in the tests against a 26.10 server.

Type names from the server always carry explicit values, so reads are not affected. No public API changes. A bare Enum('a' = 127, 'b') now becomes Enum16, because b gets 128 and the width check from #3342 runs after the numbering.

Tests. ClickHouseColumnTest has new positive and negative cases. RowBinaryFormatWriterTest has four more rows that create the table with the same type name, write with the client numbers and read the label back.

Closes #3344

Checklist


Note

Medium Risk
Changes core Enum parsing used by schemas, binary writers, and JDBC; behavior shifts for hand-written type strings but server-returned enums with explicit values are unchanged.

Overview
Enum type names written without explicit values (e.g. Enum8('a', 'b')) now parse instead of failing with Invalid enum entry. ClickHouseEnum no longer splits entries on the last =; it finds the end of a quoted name (including escaped quotes and names like 'x=y') and then reads an optional = value.

Entries missing a value are auto-numbered like ClickHouse: base is the first entry’s value, or 1 if the first has none, plus each entry’s index. Partial mixes (some but not all later entries having values) are rejected, matching the server. That also affects bare Enum width (e.g. Enum('a' = 127, 'b') can resolve to Enum16 after implicit numbering).

Tests cover unit cases in ClickHouseColumnTest and integration round-trips in RowBinaryFormatWriterTest; changelog notes client-v2/jdbc-v2 impact (#3344).

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

ClickHouseEnum split each entry on the last '=' and required a value, so
type names like Enum8('a', 'b') or Enum8('a' = 5, 'b') failed with
"Invalid enum entry", and a quoted name with '=' inside was split in the
wrong place.

Read the quoted name first and then an optional value. Give an entry
without a value the first value plus its position, or 1 plus its position
when the first entry has no value, as the server does. Keep rejecting
lists where only some entries after the first one have a value.

Closes ClickHouse#3344
@Indian-boult
Indian-boult requested review from a team and mzitnik as code owners November 17, 2026 19:23
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] Enum type name without explicit values (Enum8('a', 'b')) fails to parse: Invalid enum entry

1 participant