Skip to content

Remove the Apache Arrow library reader and writer for the Arrow formats - #111996

Merged
alexey-milovidov merged 14 commits into
masterfrom
remove-arrow-library-formats
Aug 2, 2026
Merged

alexey-milovidov merged 14 commits into
masterfrom
remove-arrow-library-formats

Conversation

@alexey-milovidov

@alexey-milovidov alexey-milovidov commented Jul 27, 2026 •

Copy link
Copy Markdown
Member

Related: #110074

The native ClickHouse Arrow IPC reader and writer became the default for the Arrow and ArrowStream formats in 26.7, selected by input_format_arrow_use_native_reader and output_format_arrow_use_native_writer. This removes the Apache Arrow C++ library-based implementations they superseded, so the native one is the only path.

ArrowBlockInputFormat and ArrowBlockOutputFormat are deleted, and the format registration, embedded documentation and schema-cache getters move into ArrowIPC/ArrowIPCBlockInputFormat.cpp and ArrowIPC/ArrowIPCBlockOutputFormat.cpp. ArrowBufferedOutputStream goes with them: it existed only to adapt a WriteBuffer to the Apache Arrow writer API. The rest of ArrowBufferedStreams stays, because the native Parquet and ORC readers, Arrow Flight and DeltaLake still use it.

Both settings are made obsolete rather than deleted, so queries that still set them keep working and are ignored, mirroring how input_format_orc_use_fast_decoder was retired when the Apache Arrow-based ORC reader was removed in #110074.

Behavior change and migration. This is backward incompatible because it removes a user-visible opt-out, not only dead code: a query that set input_format_arrow_use_native_reader = 0 or output_format_arrow_use_native_writer = 0 to force the Apache Arrow library implementation previously got that implementation, and now silently gets the native one. SET compatibility = '26.6' does not bring the old implementation back either, since the code is gone. There is no migration action for the common case — the native implementation has been the default since 26.7, so anyone who did not explicitly opt out is unaffected, and the settings can simply be dropped from queries, profiles and client configurations. Anyone still pinning the old path should first check the affected queries against the native implementation on 26.7, where both are still available and the setting still switches between them; for a genuine incompatibility, please report it as a bug in the native reader or writer rather than relying on the removed one.

This does not remove contrib/arrow, which is still required for Arrow Flight, DeltaLake, and the low-level utilities the native Parquet code uses. It removes the last format-level consumer of the Apache Arrow reader/writer.

Note on test coverage: several tests asserted that the native implementation agreed with the library one. With the library gone those would have degenerated into comparing a query against itself and always passing, so they now make golden assertions on the native output instead. 04341_native_arrow_ipc_column_pruning checks a subset read against reading every column and then projecting, which is a real invariant and keeps its original reference. Cross-implementation coverage is retained by the pyarrow-based tests (04330, 04338, 04343, 04344, 04497, 04613), which produce and consume Arrow files with an independent implementation, and 04315, 04316, 04317 and 04320, which previously generated their input with the Apache Arrow writer, now cross-check the native output by decoding it with pyarrow instead of degenerating into ClickHouse-only round-trips. 04314 is a native round-trip, with the equivalent cross-implementation coverage in the tests named above.

Verified locally: the full arrow stateless suite passes, and the Arrow/ArrowStream round-trips and obsolete settings were smoke-tested against a server built from this branch.

Changelog category (leave one):

  • Backward Incompatible Change

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

Removed the Apache Arrow library-based reader and writer for the Arrow and ArrowStream formats. The native ClickHouse implementation, which has been the default since 26.7, is now the only one. The settings input_format_arrow_use_native_reader and output_format_arrow_use_native_writer are obsolete: they are still accepted, but have no effect, so a query that set them to 0 to force the Apache Arrow implementation now uses the native one.

The native ClickHouse Arrow IPC reader and writer became the default for the
`Arrow` and `ArrowStream` formats in 26.7, selected by
`input_format_arrow_use_native_reader` and
`output_format_arrow_use_native_writer`. This removes the Apache Arrow C++
library-based implementations they superseded, so the native one is the only
path.

`ArrowBlockInputFormat` and `ArrowBlockOutputFormat` are deleted, and the
format registration, embedded documentation and schema-cache getters move to
`ArrowIPC/ArrowIPCBlockInputFormat.cpp` and
`ArrowIPC/ArrowIPCBlockOutputFormat.cpp`. `ArrowBufferedOutputStream` goes with
them: it adapted a `WriteBuffer` to the Apache Arrow writer API and had no
other user. The rest of `ArrowBufferedStreams` stays, since the native
Parquet/ORC readers, Arrow Flight and DeltaLake still use it.

Both settings become obsolete rather than being deleted, so existing queries
that set them keep working (they are ignored). This mirrors how
`input_format_orc_use_fast_decoder` was retired when the Apache Arrow-based ORC
reader was removed in #110074.

Tests that compared the native implementation against the library one would
have silently degenerated into comparing a query with itself, so those
assertions are replaced with golden assertions on the native output; the
pruned-read test instead checks a subset read against reading every column and
projecting, which is a real invariant. Cross-implementation coverage is
retained by the pyarrow-based tests, which read and write Arrow files with an
independent implementation. `04648_arrow_use_native_obsolete_setting` keeps the
obsolete-setting compatibility path exercised.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
@clickhouse-gh

clickhouse-gh Bot commented Jul 27, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [d46e243]

Summary: ✅


AI Review

Summary

This PR removes the Apache Arrow C++ library-based Arrow / ArrowStream reader and writer, makes the old selector settings obsolete, moves the remaining format registration and embedded docs onto the native IPC implementation, and rewrites the affected tests around the native path. The implementation and compatibility wiring look coherent overall, but one writer-oriented regression test still lost its independent oracle and now only proves a ClickHouse self-round-trip.

Findings

⚠️ Majors

  • tests/queries/0_stateless/04349_native_arrow_ipc_const_dictionary.sh:32 04349 is supposed to guard the constant-LowCardinality dictionary path in the native writer, where ColumnConst materialization happens before dictionary substitution. After removing the old reader/writer switch, the test now reads the file back only through ClickHouse itself, so a bug in dictionary-batch or index encoding that the native reader also tolerates would still pass. Please keep an outside consumer here as well, e.g. a pyarrow read of both Arrow and ArrowStream outputs that pins the emitted schema or rows.
Final Verdict

Changes requested.

@clickhouse-gh clickhouse-gh Bot added the pr-improvement Pull request with some product improvements label Jul 27, 2026
@mintlify

mintlify Bot commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

Preview deployment for your docs. Learn more about Mintlify Previews.

Project Status Preview Updated (UTC)
ClickHouse-docs 🟢 Ready View Preview Jul 27, 2026, 12:41 AM

@Algunenano Algunenano self-assigned this Jul 27, 2026

@Algunenano Algunenano left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. There are a couple of issues already flagged:

  • We should not edit translations. Let's teach Claude about it.
  • It doesn't build in fasttest (some missing linked file?)

Algunenano and others added 4 commits July 27, 2026 11:43
The Arrow format registration functions moved into ArrowIPC/, which CMake
compiles only under `if (USE_ARROW)`. Fast test builds with
`-DENABLE_LIBRARIES=0`, so that translation unit (and the `#else` stubs it
carried) was dropped, leaving the unconditional calls in `registerFormats.cpp`
as undefined symbols at link time.

Guard the Arrow declarations and calls with `#if USE_ARROW`, mirroring the
existing `USE_HIVE` handling in the same file, and drop the now-dead `#else`
stub blocks from the ArrowIPC translation units.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Revert the changes to the translated (`docs/ar`, `docs/es`, `docs/fr`,
`docs/ja`, `docs/ko`, `docs/pt-BR`, `docs/ru`, `docs/zh`) and generated
(`docs/reference`, `docs/_site`, `docs/snippets`) documentation trees. These
are produced from the English source and from the C++ definitions by separate
translation and generation pipelines, and direct edits are overwritten by the
next sync. Only `docs/en` is edited by hand.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Making a setting obsolete needs no dedicated test: the settings framework
accepts and ignores obsolete settings generically, so the test exercised the
framework rather than any real behavior.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Record that only `docs/en` is hand-editable and that obsoleting a setting
needs no dedicated test, so the same review feedback need not be repeated.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
…y-formats

Conflict: `master` updated two settings doc links inside the embedded
documentation of `ArrowBlockInputFormat.cpp`, which this branch deletes.
Resolved by keeping the deletion and applying the same link updates to
`ArrowIPC/ArrowIPCBlockInputFormat.cpp`, where that documentation now lives.
Both tests had degenerated into pure ClickHouse round-trips once the Apache
Arrow library implementation was removed, so a bug shared by the native writer
and the native reader would have passed unnoticed. Restore an outside opinion
using `pyarrow`, which is an implementation independent of both:

- `04315_native_arrow_ipc_reader_nested`: the natively written file is now also
  decoded by `pyarrow`, and the same nested `Array` / `Tuple` / `Map` and
  `LowCardinality(Nullable(...))` data is additionally produced by `pyarrow` and
  read back with the native reader, which must return exactly the same rows.
- `04319_native_arrow_ipc_extra_types`: the natively written file is decoded by
  `pyarrow`, asserting that the `UUID` column still advertises the `arrow.uuid`
  extension name and that the `IPv6` / `Int128` / `Int256` fixed-size-binary
  payloads have the expected layout.

The `pyarrow` output is printed in a version-independent way: extension types
are resolved through `BaseExtensionType` or the `ARROW:extension:name` field
metadata, and values are taken from the storage array rather than from whatever
Python object a given `pyarrow` release boxes them into. Verified that both
tests produce identical output with `pyarrow` 22.0.0, the version pinned in
`ci/docker/stateless-test/requirements.txt`, and with 24.0.0.
@alexey-milovidov

Copy link
Copy Markdown
Member Author

@groeneai, investigate the failure: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=111996&sha=45889523a9d342ccecedb8dce69081922db4bee5&name_0=PR&name_1=Stateless%20tests%20%28amd_msan%2C%20WasmEdge%2C%20parallel%2C%202%2F2%29 and provide a fix in a separate PR. If the fix is already in progress, link it here.

02524_fuzz_and_fuss_2 failed with TIMEOUT_EXCEEDED (elapsed 11056.432 ms, maximum: 9000 ms) on a trivial INSERT INTO data_a_02187 SELECT * FROM system.one that the test itself pins to max_execution_time = 9. The CI harness re-ran it 26 times with the same randomized settings and it passed every time, so this is a load-sensitive timeout under MSan rather than a real regression — the test is unrelated to this PR, which only touches the Arrow and ArrowStream formats. It has no tracking issue yet; the max_execution_time = 9 budget looks too tight for a sanitizer build.

@groeneai

Copy link
Copy Markdown
Collaborator

Investigated. This is not caused by your PR, and I will send the fix in a separate PR.

What happened. The max_execution_time = '9' inside the test's fuzzer settings blob is a plain wall-clock cap. It fired from the background checker (CancellationChecker: Cancelling the task because of the timeout: 9000 ms) 9.08 s after the statement started, and the server log has no progress line at all for that query between +0.08 s and the cancellation, so the 11 s is host starvation on the runner, not work inside the statement. Driving the exact statement from the test against a current master binary takes 0.14 s.

Breadth. 2 hits over 60 days across 2 unrelated PRs (this one and 110970), 0 on master, both on Stateless tests (amd_msan, WasmEdge, parallel, 2/2), both the same statement with the same 9000 ms budget (elapsed 11056 ms here, 9490 ms on 110970). The three older rows for this test are a CIDB quota error and two host memory-limit errors, so they are a different class. The rerun diagnosis (Runs: 26, Failed: 0 with the same randomized settings) rules out a randomization draw.

Why the budget has no headroom on that flavour. Over 8042 passing runs in 30 days the whole test file takes p50 2.17 s / p95 3.21 s / max 50.9 s on amd_msan, WasmEdge, against p50 0.31 s / p95 0.81 s elsewhere. 24 of those passing runs (0.30%) already spend more than 9 s in the test file as a whole, so a 9 s cap on one statement inside it is a coin flip under load.

The pin is defensive, not load-bearing. The test exists for #38729 (Block structure mismatch in Pipes stream), its reference file is empty, and EXPLAIN PIPELINE for the statement is byte identical with and without the setting, so removing it does not weaken any assertion. As a control, lowering it to 0.001 does still raise TIMEOUT_EXCEEDED, confirming it is nothing but a wall-clock guard. Raising it is also a known dead end: it was already raised from 3 to 9 for exactly this class in #67867.

So I plan to drop max_execution_time = '9' from the settings blob rather than raise it again. I will post the PR link in this thread.

@groeneai

Copy link
Copy Markdown
Collaborator

Fix PR: #112251

It drops max_execution_time = '9' from the settings blob of 02524_fuzz_and_fuss_2, which is the shape I described above. One file, one line.

…320 and 04342

Without the Apache Arrow library reader and writer these three tests became pure ClickHouse
round-trips, so a bug shared by the native writer and the native reader would pass unnoticed.
Bring back an outside consumer, `pyarrow`:

- `04316`: read the natively written `Arrow` file with `pyarrow` (asserting it really contains more
  than one record batch), and add a `pyarrow`-produced `Arrow` file with several record batches and a
  dictionary batch of its own layout, which the native reader must traverse through the footer -
  including the metadata-only `count()` path.
- `04320`: decode the natively written stream with `pyarrow` for both values of
  `output_format_arrow_string_as_string`, so a malformed variable-width `Utf8` / `Binary`
  offsets+data layout that the native reader tolerates cannot pass.
- `04342`: read the natively written `Arrow` and `ArrowStream` files with `pyarrow` and print the
  emitted schema, which pins the nested `LowCardinality` columns to a nested Arrow dictionary
  (`list<item: dictionary<…>>`, `struct<1: dictionary<…>>`, `map<dictionary<…>, …>`) instead of
  materialized plain values.

The `pyarrow` output is printed in a version-independent way (storage bytes for the `FixedString`
values, a normalized rendering of nested values, a boolean instead of the batch count), and the
references were verified to be identical under `pyarrow` 22.0.0 - the version pinned in
`ci/docker/stateless-test/requirements.txt` - and 24.0.0.
Pulls in the revert `0aae1c26958` of "Fix stale and deleted rows when reading a
`MaterializedPostgreSQL` database through `Merge`", which is what made
`test_postgresql_replica_database_engine` fail on this branch (the server refused connections).
…in 04317

The AI review noted that after removing the Apache Arrow library reader and writer,
04317 degenerated into a ClickHouse-only round-trip over its wide type matrix, so a
bug shared by the native writer and the native reader could pass unnoticed. Now the
natively written `Arrow` and `ArrowStream` files are also decoded by `pyarrow`, an
independent Arrow implementation, printing the schema and all rows. Values are
normalized (ISO dates and timestamps, hex bytes) so the reference does not depend on
which timezone library `pyarrow` picks up.

#111996
Comment thread src/Core/FormatFactorySettings.h Resolved
@alexey-milovidov
alexey-milovidov requested a review from a team as a code owner July 31, 2026 21:07
@clickhouse-gh clickhouse-gh Bot added pr-backward-incompatible Pull request with backwards incompatible changes and removed pr-improvement Pull request with some product improvements labels Jul 31, 2026
@clickhouse-gh

clickhouse-gh Bot commented Aug 2, 2026 •

Copy link
Copy Markdown
Contributor

📊 Cloud Performance Report

✅ AI verdict: no_change — no significant changes across 38 queries analysed

This PR only removes the Apache Arrow library-based reader/writer, leaving the native Arrow/ArrowStream path always on — pure format plumbing plus docs and test cleanup. Neither flagged query executes that path: ClickBench Q15 (-11.7%, CPU flat) and TPC-H Q7 (+11.6%) are ordinary SELECT/join/aggregation queries whose deltas fall within master's normal variance band. Both are run-to-run noise, not effects of this change, and the deterministic verdicts (no_change and not_sure) stand.

clickbench

🟢 No significant changes

tpch_adapted_1_official

⚠️ 1 inconclusive

Flagged queries (1 of 22)
Query Verdict Baseline median (ms) PR median (ms) Change q-value Hint
⚠️ 7 not_sure 561 626 +11.6% <0.0001 Q7 exercises server-side join/aggregation, not the Arrow format code this PR touches, so +11.6% cannot be a PR effect. It sits within master's current variance band and stays correctly marked not_sure.

Change = percent below ×2; the ratio of medians (×N faster/slower) beyond, where percent understates the scale. q-value = BH-FDR adjusted p; smaller is stronger evidence. MIRAI flags a query when q < fdr_q (default 0.10) — the value the verdict is based on.

Debug info
  • StressHouse run: edca581e-661f-433a-bced-9ab3c499f671
  • MIRAI run: 6abec2bc-f16e-46c0-8c21-1c00e93d7fd6
  • PR check IDs:
    • clickbench_1353127_1785668119
    • clickbench_1353133_1785668119
    • clickbench_1353145_1785668119
    • tpch_adapted_1_official_1353159_1785668119
    • tpch_adapted_1_official_1353171_1785668119
    • tpch_adapted_1_official_1353197_1785668119

`04341_native_arrow_ipc_column_pruning` compared the pruned read against a
subquery that `RemoveUnusedProjectionColumnsPass` shrinks back to the same
column subset, so the reader was compared against itself. Materialize
`SELECT *` into a temporary table instead - the `INSERT` of every column is a
barrier the analyzer cannot see through.

`04413_native_arrow_ipc_unsupported_types_as_binary` only round-tripped
`BFloat16` through the native writer and reader, so a bug shared by both sides
would pass. Read the file back with `pyarrow` as well and assert the field is
an Arrow `binary` column carrying the raw `BFloat16` bytes.
library=$(${CLICKHOUSE_LOCAL} --query "SELECT lc, arr_lc, tup_lc FROM file('${DATA_FILE}.${FMT}', '${FMT}') ORDER BY tup_lc.2 SETTINGS input_format_arrow_use_native_reader = 0")
if [ "$native" = "$library" ]; then echo "OK native==library | ${FMT}"; echo "$native"; else echo "MISMATCH | ${FMT}"; fi
echo "| ${FMT}"
${CLICKHOUSE_LOCAL} --query "SELECT lc, arr_lc, tup_lc FROM file('${DATA_FILE}.${FMT}', '${FMT}') ORDER BY tup_lc.2"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test used to prove more than it does now. After the input_format_arrow_use_native_reader / output_format_arrow_use_native_writer switch was removed, it only round-trips the native writer through the native reader, but the contract here is specifically that the constant-LowCardinality dictionary path in the native writer emits Arrow bytes that an outside consumer accepts. If the ColumnConst materialization or dictionary batch/index encoding is wrong in a way the native reader also tolerates, this still passes.

I do not see another pyarrow-based check covering this constant-dictionary path, so please keep an independent read here as well (for example, decode both Arrow and ArrowStream with pyarrow and assert the schema or rows).

@clickhouse-gh

clickhouse-gh Bot commented Aug 2, 2026

Copy link
Copy Markdown
Contributor

LLVM Coverage Report

Metric Baseline Current Δ
Lines 86.50% 86.50% +0.00%
Functions 91.90% 91.90% +0.00%
Branches 78.70% 78.70% +0.00%

Changed lines: Changed C/C++ lines covered: 349/350 (99.71%) · Uncovered code

Full report · Diff report

@alexey-milovidov
alexey-milovidov added this pull request to the merge queue Aug 2, 2026
Merged via the queue into master with commit 10e4cfd Aug 2, 2026
179 checks passed
@alexey-milovidov
alexey-milovidov deleted the remove-arrow-library-formats branch August 2, 2026 15:25
@robot-ch-test-poll4 robot-ch-test-poll4 added the pr-synced-to-cloud The PR is synced to the cloud repo label Aug 2, 2026
alexey-milovidov added a commit to nihalzp/ClickHouse that referenced this pull request Aug 14, 2026
…e_binary`

The Apache Arrow library reader for the `Arrow` formats was removed in ClickHouse#111996,
so `input_format_arrow_use_native_reader` is an obsolete no-op and the two loops
over both readers now ran the same reader twice. Each file is read once, and the
notes about what the library reader could not read are gone: unions and NULL
list/map slots spanning a non-empty range are no longer special.

`04512` also moves its out-of-range day number to the end of the `Date32` range
that ClickHouse#111534 extended, since `2299-12-31 + 100` is a valid date now.

`04513` gains the `fixed_size_binary` leaves the ClickHouse writer uses for
`UUID`, `IPv6` and the 128/256-bit integers, including the self-describing Arrow
`uuid` extension type, which the review asked for. These are crafted inline with
`pyarrow` (as `04613` does) instead of shipping three more binary fixtures - the
layout is easier to review as code, and it doubles as documentation of how the
committed fixtures were made.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr-backward-incompatible Pull request with backwards incompatible changes 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.

4 participants