Skip to content

Cherry pick #132416 to 26.10: Declare raw-byte leaves of Arrow IPC columns with their decoded type - #132841

Merged
robot-ch-test-poll2 merged 6 commits into
backport/26.10/132416from
cherrypick/26.10/132416
Nov 19, 2026
Merged

robot-ch-test-poll2 merged 6 commits into
backport/26.10/132416from
cherrypick/26.10/132416

Conversation

@robot-clickhouse-ci-2

Copy link
Copy Markdown
Contributor

Original pull-request #132416

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

KochetovNicolai and others added 5 commits November 17, 2026 16:36
A dotted header column such as `t.s IPv6` makes the native Arrow IPC
reader decode the binary child `s` of the struct `t` as `IPv6`. When the
parent `t` is requested too, with a type that does not describe `s` (for
example `String`), the decoded `t` still declared the child as `String`,
because its declared type comes from the Arrow schema. The raw-byte rewrite
after decoding follows the parent target type only, so it did not reconcile
the child, and the cast of `t` read the `IPv6` column as a `ColumnString`.

`matchColumnNullability` already walks the declared type alongside the
decoded column. Extend it to leaves: a `String` or `FixedString` leaf that
was decoded as `IPv6` or a big integer is declared with that type.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…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]>
…d type

The values of an Arrow dictionary are decoded once for each use: the position of a field encoding
it, and the requested type hint the field resolves there. The uses were deduplicated and the
decodings registered by position alone, but two fields at one position can resolve different
hints: a field literally named `t.u` takes the type requested for `t.u`, while the child `u` of a
struct `t` takes the type of `u` in a requested `t Tuple(...)`. When such fields shared a dictionary
id, both read the decoding of whichever came first in the schema. For example, with
``t Tuple(u UUID), `t.u` String`` the field named `t.u` returned the 36-byte text of a `UUID`
instead of its 16 bytes, and requesting it as `IPv6` threw.

Key the uses and the registry by the position together with the hint, and look the decoding up with
the use that `decodeField` and `decodeBatchColumn` resolve for the field. A use missing from the
registry is now a `LOGICAL_ERROR` instead of a `std::out_of_range`.

Review: #132416 (comment)
Co-authored-by: Yakov Olkhovskiy <[email protected]>
…-consistency

Declare raw-byte leaves of Arrow IPC columns with their decoded type
@robot-clickhouse-ci-2 robot-clickhouse-ci-2 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-critical-bugfix labels Nov 19, 2026
@cla-assistant

cla-assistant Bot commented Nov 19, 2026 •

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you all sign our Contributor License Agreement before we can accept your contribution.
2 out of 3 committers have signed the CLA.

✅ KochetovNicolai
✅ yakov-olkhovskiy
❌ cursoragent
You have signed the CLA already but the status is still pending? Let us recheck it.

Resolve the conflicts of the cherry-pick of #132416 to 26.10. The fix applies in full; the differences
from the original diff come only from master-only neighbours that 26.10 does not have:

- `RecordBatchDecoder.cpp`: 26.10 has no `TypeKind::RunEndEncoded` case in `collectDictionaryUses`
  (run-end encoding, #126207, is master-only), so there is no call to pass `below_union` to there.
  The struct case keeps the 26.10 helpers `tupleElementHint` / `childPath` (master renamed them in
  #125674) and passes `below_union` as the original change does.
- `RecordBatchDecoder.cpp`: include `base/scope_guard.h` for the two new `SCOPE_EXIT` uses. On master
  the include came with the big-endian reader (#126562); 26.10 does not include it, directly or
  transitively.
- `RecordBatchDecoder.h`: no `[[nodiscard]]` on the changed declarations, as on the rest of the 26.10
  file (master added them in #126158).

Co-authored-by: yakov <[email protected]>
@robot-ch-test-poll2
robot-ch-test-poll2 merged commit a09fa21 into backport/26.10/132416 Nov 19, 2026
1 of 2 checks passed
@robot-ch-test-poll2
robot-ch-test-poll2 deleted the cherrypick/26.10/132416 branch November 19, 2026 21:48
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-cherrypick Cherry-pick of merge-commit before backporting. Do not use manually - automated use only! pr-critical-bugfix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants