Skip to content

Cherry pick #130279 to 26.9: Fix reading ORC lists and maps whose element struct has none of the requested fields - #130776

Merged
robot-clickhouse-ci-2 merged 6 commits into
backport/26.9/130279from
cherrypick/26.9/130279
Nov 11, 2026
Merged

robot-clickhouse-ci-2 merged 6 commits into
backport/26.9/130279from
cherrypick/26.9/130279

Conversation

@robot-ch-test-poll3

Copy link
Copy Markdown
Contributor

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-pick locally.
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:

  • delete the pr-cherrypick label from the PR
  • delete this branch from the repository

You also need to check the Original pull-request for pr-backports-created label, and delete if it's presented there

The PR source

The PR is created in the CI job

groeneai and others added 5 commits November 9, 2026 07:03
…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
@robot-ch-test-poll3 robot-ch-test-poll3 added pr-cherrypick Cherry-pick of merge-commit before backporting. Do not use manually - automated use only! do not test disable testing on pull request pr-bugfix Pull request with bugfix, not backported by default labels Nov 11, 2026
The conflicts come from the `-WithMemoryTracking` containers of #126530,
which 26.9 does not have: the new code uses std::unordered_set and
std::vector, like the rest of the file on 26.9.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@groeneai

Copy link
Copy Markdown
Collaborator

The conflicts are only the container types: 26.9 does not have the -WithMemoryTracking containers of #126530, so the new code uses std::unordered_set and std::vector, like the rest of the file there.

git fetch https://github.com/groeneai/ClickHouse resolve-26.9-cherrypick-130279 && git push origin FETCH_HEAD:cherrypick/26.9/130279
  • 3c373d8df193 is a fast-forward from the cherry-pick head 9e17b5d05ef4. Compared with backport/26.9/130279 it changes only this PR's 4 files, with the same lines apart from the container types.
  • On a 26.9 build (Debug, clang-22) the test passes 3/3. The official 26.9.26.11 binary fails it: it returns [] for the list of id 0 and crashes with SIGSEGV on the map read.

@robot-clickhouse-ci-2
robot-clickhouse-ci-2 merged commit 5f08b57 into backport/26.9/130279 Nov 11, 2026
2 checks passed
@robot-clickhouse-ci-2
robot-clickhouse-ci-2 deleted the cherrypick/26.9/130279 branch November 11, 2026 14:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

do not test disable testing on pull request pr-bugfix Pull request with bugfix, not backported by default pr-cherrypick Cherry-pick of merge-commit before backporting. Do not use manually - automated use only!

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants