Repository navigation
[client-v2] Parse Enum type names that leave out the values - #3366
Closed
Indian-boult wants to merge 2 commits into
Closed
Indian-boult wants to merge 2 commits into
Indian-boult wants to merge 2 commits into
Conversation
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
This was referenced Nov 18, 2026
1 task
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
ClickHouseEnum read each entry by splitting on the last
=and required a value. The server allows entries without a value and numbers them itself, soEnum8('a', 'b')failed in the client withInvalid 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
autoAssignNumberForEnumon 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 becomesEnum16, becausebgets 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 withInvalid enum entry.ClickHouseEnumno 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
1if 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 bareEnumwidth (e.g.Enum('a' = 127, 'b')can resolve to Enum16 after implicit numbering).Tests cover unit cases in
ClickHouseColumnTestand integration round-trips inRowBinaryFormatWriterTest; 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.