Repository navigation
Fix UUID dictionary leaves and union children that the Arrow IPC reader declared with the wrong type - #132550
Merged
cursor[bot] merged 2 commits intoNov 18, 2026
Conversation
…ded type A dictionary-encoded `fixed_size_binary(16)` child is converted to `UUID` when a dotted header column such as `t.u UUID` requests it: `decodeDictionaryBatch` rewrites the dictionary values with `reinterpretRawByteColumns`. `rawByteLeafType` listed only the types that `reinterpretStringLeaf` produces, so `matchColumnNullability` kept declaring the leaf as `FixedString(16)`. When the parent `t` was requested too, with a type that does not describe `u` (for example `String`), the cast of `t` read the `UUID` column as a `FixedString` one: a failed `assert_cast` in debug builds, undefined behavior in release builds. Declare such a leaf as `UUID`, and throw a `LOGICAL_ERROR` for a `String` or `FixedString` leaf that holds a column of any other type, so a conversion this walk does not know becomes an exception instead of undefined behavior. Review: #132416 (comment) Related: #132416 Co-authored-by: Yakov Olkhovskiy <[email protected]>
The children of an Arrow union restart the dotted path, so the struct child `s` of a union child has the path `s`, and the lookup in the requested types found the unrelated header column `s`. Its type changed how the child decodes (raw bytes read as `IPv6`, or the null map of a struct kept for a `Tuple`), while `decodeUnion` declares its children from the Arrow schema, so the cast of the union read the column as another type: a failed `assert_cast` in debug builds, a segmentation fault in release builds. A dictionary of a field below a union got the same hint, from `collectDictionaryUses` and again in `decodeDictionaryValues`. Look up no requested type while decoding the children of a union, and the values of a dictionary used below one. Keep these dictionary positions apart from equally named positions outside the union (`FieldPosition::below_union`), so a dictionary that a field outside the union shares does not hand the union the decoding requested for that field. Review: #132416 (comment) Related: #132416 Co-authored-by: Yakov Olkhovskiy <[email protected]>
|
|
cursor
Bot
merged commit Nov 18, 2026
b5ef697
into
arrow-ipc-nested-hint-type-consistency
3 of 4 checks passed
groeneai
added a commit
to groeneai/ClickHouse
that referenced
this pull request
Nov 19, 2026
The branch is in conflict with master. Conflicts in the ArrowIPC reader only: master (ClickHouse#132416) keys the dictionary uses and the registry by position and requested hint (`DictionaryUse::operator==`, `DictionaryRegistry::useKey`, `dictionaryUse`), as this branch did with `DictionaryUse::key`; master's code is kept and the branch's copy dropped. Master's `below_union` position (ClickHouse#132550) is kept with this branch's exact-name hint lookup (`resolveHint` with case-insensitive matching), the per-struct `structFieldHints` and the top-level field name as the starting path. Co-Authored-By: Claude Opus 5.5 <[email protected]>
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.
Two fixes on top of #132416, for findings from its review. In both, the type declared for a decoded Arrow IPC column did not describe the column, so the cast of the column read it through the serialization of another type: a failed
assert_castin debug builds, a segmentation fault or garbage output in release builds. Each fix is a separate commit, so either can be taken into the branch of #132416 on its own.UUIDdictionary leaves (Declare raw-byte leaves of Arrow IPC columns with their decoded type #132416 (comment)). A dictionary-encodedfixed_size_binary(16)child is converted toUUIDwhen a dotted header column such ast.u UUIDrequests it, butrawByteLeafTypedid not listUUID, so readingt String, `t.u` UUIDstill declared the child asFixedString(16). It is listed now, and aStringorFixedStringleaf that holds a column of any other type throws aLOGICAL_ERRORinstead of reaching the cast.sof a union child picked up the requested type of an unrelated header columns, whiledecodeUniondeclares its children from the Arrow schema. Besides the raw-byte case from the comment, the same leak kept the null map of a nested struct whenswas requested as aTupleunderenable_nullable_tuple_type = 0, so reconciling theVariantalternatives would not have been enough. Requested types are no longer looked up below a union: neither while decoding its children, nor for the dictionaries of fields below it. Dictionary positions below a union are kept apart from equally named positions outside it, so a dictionary shared with a field outside the union cannot hand the union that field's decoding.Tests:
05828_arrow_ipc_dictionary_raw_byte_hint_parent_type,05829_arrow_ipc_union_unrelated_hint, and05830_arrow_ipc_union_dictionary_unrelated_hint. The last one needs pyarrow (henceno-fasttest), because the ClickHouse writer does not dictionary-encode inside a union. EveryUUIDand union case in them aborts the debug build of #132416 atdbc60529and passes with these commits. The first commit alone fixes 05828 and leaves the union cases failing.Verified on a local Debug build in the fast-test configuration:
base64Decode, brotli);Arrow/ArrowStreamrows of05361_arrow_testing_corpusmatch the reference.This PR targets the branch of #132416, so CI does not run on it.
Related: #132416
Changelog category (leave one):