Skip to content

Read Arrow RunEndEncoded columns - #126207

Merged
alexey-milovidov merged 6 commits into
ClickHouse:masterfrom
JayPokale:arrow-run-end-encoded
Oct 19, 2026
Merged

alexey-milovidov merged 6 commits into
ClickHouse:masterfrom
JayPokale:arrow-run-end-encoded

Conversation

@JayPokale

@JayPokale JayPokale commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

Closes: #125146

The native Arrow IPC reader now reads RunEndEncoded columns as their values type, instead of rejecting them with UNKNOWN_TYPE.

A run-end-encoded field has no buffers of its own and two children: run_ends (Int16, Int32 or Int64, the exclusive end of each run) and values (one value per run). RecordBatchDecoder::decodeRunEndEncoded:

  • decodes the run ends and checks that they are positive, strictly increasing, without nulls, and cover every row;
  • maps every row to its run with one index column, and marks a run invisible when all of its rows are invisible (or when it is past the last row), so its value is not validated;
  • decodes the values with the field's own hint, path and list depth, so requested types and dictionary uses work as for the field itself, and expands them with IColumn::index.

decodeField handles the field before the validity buffer (it has none, like Union and Null); the nulls are the nulls of the values. fieldToCHType maps the field to its values type, and collectDictionaryUses descends into the values. Dictionary-encoded values are materialized, as for a nested dictionary, so the inferred type and the decoded column agree. The schema parser now checks that the run ends are an integer field. SkipLayout::RunEndEncoded is removed; advanceField skips the type as before.

Tests:

  • 05404_arrow_run_end_encoded: a pyarrow-written file and stream with Int16, Int32 and Int64 run ends, a null value, dictionary-encoded values, and a run-end-encoded field of a struct, with inferred and explicit structures.
  • 04345_native_arrow_ipc_skip_unsupported_column used RunEndEncoded as an example of a type that can be skipped but not read; requesting it now returns the values.

Changelog category (leave one):

  • Improvement

Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):

The Arrow and ArrowStream input formats can read RunEndEncoded columns.


Workflow [PR]
Sync PR [sync-upstream/pr/126207]

Version info

  • Merged into: 26.11.1.207-master (included in 26.11 and later)

@clickhouse-gh clickhouse-gh Bot added the comp-formats Input/output formats (CSV/JSON/Parquet/ORC/Arrow/Protobuf/etc.). label Oct 16, 2026
@alexey-milovidov alexey-milovidov added the can be tested Allows running workflows for external contributors label Oct 16, 2026
@alexey-milovidov alexey-milovidov self-assigned this Oct 16, 2026
@clickhouse-gh

clickhouse-gh Bot commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [9f9c4e9]

Summary: ✅


AI Review

Summary

Adds RunEndEncoded input support to Arrow and ArrowStream, expanding runs into their values type. The current code addresses the prior findings, including nested nullability, hidden-row defaults, map keys, metadata traversal, and long runs behind wrappers. No unresolved actionable findings remain.

Missing context / blind spots
  • ⚠️ CI for 9f9c4e9e649 is still in progress. All 17 focused local cases passed on 343bc229209, including the linked Arrow corpus. The final clearLastDefaultNulls fix was verified in source and has a focused regression test, but was not executed locally at the exact head.
Final Verdict

Status: ✅ Approve. No further code changes requested; normal CI completion remains pending.

@clickhouse-gh clickhouse-gh Bot added the pr-improvement Pull request with some product improvements label Oct 16, 2026
@clickhouse-gh clickhouse-gh Bot added the external Author is not a member of the ClickHouse organization label Oct 17, 2026
JayPokale and others added 2 commits October 17, 2026 10:15
…ared runs

`hasRowsBackedByBuffers` now follows struct and fixed-size-list wrappers (and
the map entries struct), so a long run inside a struct, list or fixed-size list
is no longer rejected by the message-body row bound.

`decodeRunEndEncoded` maps a row hidden by an ancestor's validity to a default
value appended after the runs, so it decodes as the default even when it shares
its run with visible rows, like a row of an unencoded field.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…EndEncoded`

- The nulls of a `RunEndEncoded` field are those of its values: `isNullableField`
  derives the inferred and decoded nullability from the values child, regardless
  of the encoded parent's own flag, so a null run of a field declared
  non-nullable is no longer replaced by a default.
- Map keys are never nullable: a `Nullable` key column (the values of a
  run-end-encoded key) is unwrapped after checking that no key is null.
- `hasRowsBackedByBuffers` ignores bufferless (`Null`) children of a struct or
  fixed-size-list wrapper, so a struct of a long run and a `Null` field is not
  checked against the message body as if the `Null` field had buffers.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…alued `RunEndEncoded` run

`insertDefault` on a `Tuple` inserts NULL into its `Nullable` elements, so a row hidden by a null
ancestor in a struct-valued run decoded with nested NULLs, unlike the same unencoded field. Clear the
null bits recursively through `Nullable` and `Tuple` (`clearLastDefaultNulls`), keeping only the `Null`
type null.

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

Copy link
Copy Markdown
Member

🕵 @groeneai, investigate the failure: https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=126207&sha=343bc229209745a783a3429421faec2d56772161&name_0=PR&name_1=Unit%20tests%20%28asan_ubsan%2C%20function_prop_fuzzer%29 (FunctionsStress.stress, unrelated to the Arrow IPC reader changed here) and provide a fix in a separate PR. If the fix is already in progress (possibly #126210), link it here.

@groeneai

Copy link
Copy Markdown
Collaborator

The fix is in progress: #126210. The stuck worker at 343bc229 (173.5 s on range(CAST(312625 AS Int32))) has the same stack as the other occurrences: __asan_stack_malloc_1 <- PODArray::operator[] <- ColumnVector::doCompareAt <- ColumnArray::compareAtImpl <- FunctionsStressTestThread::executeFunction.

The ASan fake stack of a worker fills up with frames left behind by exceptions from failed overload resolution, after which every per-element compareAt scans the full class-1 fake stack (details: #120908 (comment)). #126210 adds a fake-stack GC point at the top of the worker loop (test harness only). Its CI has finished, with the unit tests passing; it is waiting for a review.

CIDB: 23 occurrences since 2026-10-15 (3 on master), 0 in the 640 runs of 2026-10-14.

@clickhouse-gh

clickhouse-gh Bot commented Oct 17, 2026

Copy link
Copy Markdown
Contributor

Build profile diff (arm_release)

Comparing 9f9c4e9e6 with master 76cb67e41 (stripped binary size, per-symbol sizes and ThinLTO time; compile times per translation unit against the most recent warmup build that recompiled it).

✅ No significant changes.

Binary sizes

programs/clickhouse-stripped: smaller than the master baseline by the known offset between the two builds, so the difference is not shown. A delta that differs from the offset by more than 50% of it is shown, in either direction.

The official master build is compiled with -g and a pull request build is not, and XRay counts debug instructions towards its instrumentation threshold, so master instruments thousands of functions more and its binary is ~0.4% larger no matter what the pull request does.

Object file sizes

6 object files changed (+20.66 KiB total), 0 added.

Object file Master PR Δ
src/CMakeFiles/dbms.dir/Processors/Formats/Impl/ArrowIPC/RecordBatchDecoder.cpp.o 577.57 KiB 596.16 KiB +18.59 KiB (+3.22%)

719 more object files are built by the master warmup baseline only (it builds every object-file target, a pull request build only clickhouse-bundle) and not compared.

Compile time of recompiled translation units

11 translation units recompiled, 34 s compile time in total, 11 of them have a recent master baseline.

Job report

@alexey-milovidov
alexey-milovidov added this pull request to the merge queue Oct 18, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to no response for status checks Oct 19, 2026
@alexey-milovidov
alexey-milovidov added this pull request to the merge queue Oct 19, 2026
Merged via the queue into ClickHouse:master with commit b011cc6 Oct 19, 2026
178 checks passed
@robot-ch-test-poll2 robot-ch-test-poll2 added the pr-synced-to-cloud The PR is synced to the cloud repo label Oct 19, 2026
cursor Bot pushed a commit that referenced this pull request Nov 19, 2026
Resolve the conflicts of the cherry-pick of #132416 to 26.9. The fix applies in full; the differences
from the original diff come only from master-only neighbours that 26.9 does not have:

- `ArrowIPCBlockInputFormat.cpp`: 26.9 still checks that dictionary values are unique after registering
  them (master dropped the check in #125677). Keep the check and look the values up by the dictionary use,
  as the registry is now keyed by it.
- `RecordBatchDecoder.cpp`: 26.9 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.9 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.9 does not include it, directly or
  transitively.
- `RecordBatchDecoder.h`: no `[[nodiscard]]` on the changed declarations, as on the rest of the 26.9
  file (master added them in #126158).

Co-authored-by: yakov <[email protected]>
cursor Bot pushed a commit that referenced this pull request Nov 19, 2026
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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

can be tested Allows running workflows for external contributors comp-formats Input/output formats (CSV/JSON/Parquet/ORC/Arrow/Protobuf/etc.). external Author is not a member of the ClickHouse organization pr-improvement Pull request with some product improvements pr-synced-to-cloud The PR is synced to the cloud repo

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Arrow: the RunEndEncoded type is not supported

4 participants