Repository navigation
Cherry pick #130279 to 26.8: Fix reading ORC lists and maps whose element struct has none of the requested fields - #130775
Merged
robot-clickhouse-ci-2 merged 6 commits intoNov 11, 2026
Conversation
…d fields When the requested type of a struct below an ORC list or map (an element, a map key or a map value) names none of the struct's fields, as after a schema evolution that replaced them, `updateIncludeTypeIds` selected no column under it. The ORC reader then dropped the list from the selected type, so it was read as a missing column (`[]` for every row instead of one default tuple per element), and kept a map with only one child, so the MAP read threw `std::out_of_range` from `getSubtype(1)` (abort in debug, SIGSEGV in release) or left `elements` null (SIGSEGV for a struct key). The same happens through a dotted subcolumn of a struct (`t.l`, `tm.m`) and a subcolumn of a flattened Nested column (`n.z`). Selecting a carrier column alone is not enough: its values reach the result through the positional named-tuple cast, and the read-time type hint cannot tell such a struct apart, because on the flattened-subcolumn path the hint is the type of the first subcolumn, not of the struct. So the selection collects every struct below a list or a map (and the struct a flattened Nested subcolumn resolves to) with its requested type, and after all requested columns are resolved, a struct with no included column in its subtree and no included ancestor gets its narrowest field included and is recorded as read only for its count. The STRUCT read returns the recorded type's default values for such a struct. A struct that is read today is never recorded, so every read that works today is unchanged. The values now match what the Arrow reader returns. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Shorten three two-line comments on the count-only struct candidates and map to one line each. Co-Authored-By: Claude Opus 5.5 <[email protected]>
A list element or map key/value struct that has none of the requested fields was filled with `IDataType::getDefault`, which differs from the column default for `Date32` (1900-01-01 vs 1970-01-01). Every other missing value in the ORC reader (a missing column, a missing field of a struct that has some requested fields, which goes through the tuple CAST) uses the column default, so the same absent field read a different value depending on whether another field was requested. Use `insertManyDefaultsInto`: the column default, except for Enum, which gets its first value instead of an invalid 0. Add non-nullable `Date32` and `Enum8` cases with and without an overlapping field to the test. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Replace the count-only structs with a by-name match after the read, as in the Arrow reader. A requested struct with no field read gets its narrowest field read only for its size and null map, without converting its values, and the requested elements that were not read are filled with defaults, so a CAST never matches named tuples by position. Shared reads of a struct now serve any request. Unnamed tuples are still matched by position. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ithout-requested-fields Fix reading ORC lists and maps whose element struct has none of the requested fields
The conflicts come from the `-WithMemoryTracking` containers of #126530 and from `findORCStructFieldByName` of #109741, which 26.8 does not have: the new code uses std::unordered_set and std::vector, and the recursive call keeps the name lookup of 26.8. The test enables `enable_nullable_tuple_type`, which is off by default on 26.8, and drops the five queries that read a subcolumn through a list (`tb.l.b`, `an.x.v`): 26.8 returns empty arrays for such a path even for a field that is in the file, with or without this change. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Collaborator
|
Besides the container types (26.8 does not have the
|
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.
Original pull-request #130279
Do not merge this PR manually
This pull-request is a first step of an automated backporting.
It contains changes similar to calling
git cherry-picklocally.If you intend to continue backporting the changes, then resolve all conflicts if any.
Otherwise, if you do not want to backport them, then just close this pull-request.
The check results does not matter at this step - you can safely ignore them.
Before you resolve anything
Conflicts are often caused by a prerequisite change that has not been backported yet, rather than by a real divergence. The bot re-tries this cherry-pick against the release branch on every run, so if that is the case here it will merge itself as soon as the prerequisite lands, and you will see a comment saying so. Manual resolution is only needed while the conflict persists.
Troubleshooting
If the conflicts were resolved in a wrong way
If this cherry-pick PR is completely screwed by a wrong conflicts resolution, and you want to recreate it:
pr-cherrypicklabel from the PRYou also need to check the Original pull-request for
pr-backports-createdlabel, and delete if it's presented thereThe PR source
The PR is created in the CI job