Repository navigation
fix(types): parse JSON type hints with parenthesized types - #478
Merged
Merged
Conversation
hsdfat
requested review from
abonander,
joe-clickhouse,
kavirajk and
peter-leonov-ch
as code owners
September 26, 2026 16:59
2 tasks done
remove_json_header() trimmed every trailing `)`, so `JSON(a Nullable(String))`
lost the closing paren of the hint type and failed with
`Unknown data type: Strin`. The hints were also split on commas and `=`
without regard for parentheses or string literals, which broke hint types
such as `Map(String, Int32)` or `Enum8('x' = 1)` and `SKIP REGEXP` patterns
containing a comma.
Strip exactly one closing `)` and split only on separators outside
parentheses, back-quoted names and string literals.
Fixes ClickHouse#442
abonander
force-pushed
the
json-type-hints-nested-parens
branch
from
October 6, 2026 04:59
df1cebd to
e8581d5
Compare
abonander
approved these changes
Oct 6, 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
Fixes #442.
JSONcolumns with a typed path whose type has its own parentheses could not be parsed from theRowBinaryWithNamesAndTypesheader, so reading from or inserting into such a table failed:Two independent problems in
parse_json():remove_json_header()usedtrim_end_matches(')'), stripping every trailing)instead of just the one closingJSON(, soJSON(a Nullable(String))becamea Nullable(Stringand the inner type parsed asStrin.=without tracking parentheses or string literals (only back-quoted paths were handled, since fix(types): parse back-quoted JSON path names #458). SoJSON(a Map(String, Int32))was split into two broken hints,JSON(a Enum8('x' = 1))silently lost its hint because it looked like aname=valuesetting, and aSKIP REGEXPpattern containing a comma was split as well.The fix
remove_json_header()now strips exactlyJSON(and one closing). The splitting helper introduced in #458 now also skips separators inside parentheses and single-quoted literals (renamed fromunquoted_positionstotop_level_positions), and is still used for the hint separator, the setting=check and the path/type boundary. Settings (max_dynamic_paths=N),SKIP,SKIP REGEXPand back-quoted paths behave as before; the existing tests are unchanged.Verification
New unit test
test_data_type_new_json_with_nested_hint_types, onmain:With the fix,
cargo test -p clickhouse-typespasses (44 + 1 doctest).cargo fmt -- --checkandcargo clippy -p clickhouse-types --all-targetsare clean withRUSTFLAGS=-Dwarnings.Checklist
Suggested CHANGELOG entry (Fixed):
JSONcolumns with typed paths whose type has parentheses, e.g.JSON(a Nullable(String))orJSON(a Map(String, Int32)), no longer fail to parse. ([#442])