Repository navigation
Remove the Apache Arrow library reader and writer for the Arrow formats - #111996
Conversation
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]>
|
Workflow [PR], commit [d46e243] Summary: ✅
AI ReviewSummaryThis PR removes the Apache Arrow C++ library-based Findings
Final VerdictChanges requested. |
|
Preview deployment for your docs. Learn more about Mintlify Previews.
|
Algunenano
left a comment
There was a problem hiding this comment.
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?)
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.
|
@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.
|
|
Investigated. This is not caused by your PR, and I will send the fix in a separate PR. What happened. The Breadth. 2 hits over 60 days across 2 unrelated PRs (this one and 110970), 0 on master, both on 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 The pin is defensive, not load-bearing. The test exists for #38729 ( So I plan to drop |
|
Fix PR: #112251 It drops |
…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
|
📊 Cloud Performance Report ✅ AI verdict: 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_officialFlagged queries (1 of 22)
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
|
`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" |
There was a problem hiding this comment.
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).
LLVM Coverage Report
Changed lines: Changed C/C++ lines covered: 349/350 (99.71%) · Uncovered code |
…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.
Related: #110074
The native ClickHouse Arrow IPC reader and writer became the default for the
ArrowandArrowStreamformats in 26.7, selected byinput_format_arrow_use_native_readerandoutput_format_arrow_use_native_writer. This removes the Apache Arrow C++ library-based implementations they superseded, so the native one is the only path.ArrowBlockInputFormatandArrowBlockOutputFormatare deleted, and the format registration, embedded documentation and schema-cache getters move intoArrowIPC/ArrowIPCBlockInputFormat.cppandArrowIPC/ArrowIPCBlockOutputFormat.cpp.ArrowBufferedOutputStreamgoes with them: it existed only to adapt aWriteBufferto the Apache Arrow writer API. The rest ofArrowBufferedStreamsstays, 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_decoderwas 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 = 0oroutput_format_arrow_use_native_writer = 0to 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_pruningchecks 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 thepyarrow-based tests (04330,04338,04343,04344,04497,04613), which produce and consume Arrow files with an independent implementation, and04315,04316,04317and04320, which previously generated their input with the Apache Arrow writer, now cross-check the native output by decoding it withpyarrowinstead of degenerating into ClickHouse-only round-trips.04314is a native round-trip, with the equivalent cross-implementation coverage in the tests named above.Verified locally: the full
arrowstateless suite passes, and theArrow/ArrowStreamround-trips and obsolete settings were smoke-tested against a server built from this branch.Changelog category (leave one):
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
ArrowandArrowStreamformats. The native ClickHouse implementation, which has been the default since 26.7, is now the only one. The settingsinput_format_arrow_use_native_readerandoutput_format_arrow_use_native_writerare obsolete: they are still accepted, but have no effect, so a query that set them to0to force the Apache Arrow implementation now uses the native one.