Repository navigation
Parse Enum type names that omit element numbers - #1190
Merged
joe-clickhouse merged 5 commits intoNov 16, 2026
Merged
Conversation
AI review gate — Human approval in place of AI reviewApproved on the head commit by joe-clickhouse (write access, not the author), standing in for the AI review:
What to do:
Evaluated at |
Contributor
|
Pushed a small follow-up on top of your branch. |
Signed-off-by: Joe Spadola <joe.spadola@clickhouse.com>
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.
Reviewed by Cursor Bugbot for commit dd70c59. Configure here.
joe-clickhouse
approved these changes
Nov 14, 2026
chernser
approved these changes
Nov 16, 2026
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
Closes #1189.
parse_enumexpected every element to be'name' = number, so a type name likeEnum8('a', 'b')failed withValueError: invalid literal for int() with base 10: ''. This hitget_from_nameand inserts that passcolumn_type_names, including the Nullable, Array, Tuple and Map forms.I changed
parse_enumso the= numberpart is optional, and it fills in the missing numbers the way the server does inautoAssignNumberForEnum(src/DataTypes/DataTypeEnum.cpp):igetsbase + iValueError, and so does'a' =with no numberThe numbers are filled in before the bare
Enumpicks Enum8 or Enum16, soEnum('a' = 127, 'b')becomesEnum16('a' = 127, 'b' = 128).Tests: a parametrized test checks
get_from_name(...).namefor scalar, Nullable and Array forms, a negative base, an escaped quote in a name,'x=y'as a name, and the Enum16 change. Another checks the inner Enum types for Tuple and Map (their own names keep the input string as written, same as on main), and a third checks that the mixed forms are rejected.tests/unit_tests/test_driver/test_parser.py: 122 passed; the new cases fail on main.I used Claude Code to help prepare this change; I reviewed the diff and ran the tests locally.
Checklist
Note
Low Risk
Parser-only behavior with unit test coverage; no wire format or insert encoding changes beyond correct type resolution from type names.
Overview
parse_enumno longer requires every enum member to use'name' = number. Types such asEnum8('a', 'b'), mixed forms likeEnum8('a' = 5, 'b'), and nested uses (Nullable,Array,Tuple,Map) now parse and canonicalize to explicit numbers using ClickHouse-style rules: base 1 when the first member has no value, otherwise the first member’s number, thenbase + indexfor any following members that omit a value. Elements after the first must either all specify values or all omit them; invalid mixes still raiseValueError.get_from_nameand inserts that rely oncolumn_type_names(for example bareEnum('a','b')resolving toEnum8('a' = 1, 'b' = 2)orEnum('a' = 127, 'b')toEnum16(...)) stop failing with empty-int conversion errors. CHANGELOG documents the fix;test_parser.pyadds parametrized success cases and rejection tests for malformed omitted-value syntax.Reviewed by Cursor Bugbot for commit 0465a67. Bugbot is set up for automated code reviews on this repo. Configure here.