Repository navigation
Make native Parquet independent of the Arrow library and enable it in the fast test - #126477
Conversation
… the fast test The native Parquet reader and writer called a few functions of Apache Arrow and parquet-cpp, so `USE_PARQUET` required the whole Arrow C++ library, and Parquet was disabled in the fast test. Now they depend only on the structures generated from `parquet.thrift` and a minimal Thrift runtime: - `ch_contrib::parquet_format`: `parquet_types.cpp` with `ch_contrib::thrift_minimal`, the five Thrift runtime files needed to (de)serialize structures in memory, without networking and OpenSSL. - Native bit unpacking for `DELTA_BINARY_PACKED` and decoding of `BYTE_STREAM_SPLIT`. - CRC32 from zlib. - Bloom filter hashing on `parq::SchemaElement` and `XXH64`, without `parquet::ColumnDescriptor`. - Native `PLAIN` and dictionary encoders and the RLE / bit-packed hybrid encoder in the writer. The output is byte-identical to the previous writer, which used the encoders of parquet-cpp. - The legacy Delta Lake reader reads checkpoints with the native Parquet reader. `USE_PARQUET` now means the native reader and writer, `USE_ARROW` the native `Arrow` and `ArrowStream` formats, and the new `USE_ARROW_LIBRARY` (CMake option `ENABLE_ARROW_LIBRARY`) the Apache Arrow C++ library with parquet-cpp, which is still needed for ORC, Hive, Arrow Flight, delta-kernel-rs, and the `ParquetMetadata` format. The fast test builds with `-DENABLE_PARQUET=1` and checks out the Arrow, Thrift, FlatBuffers, and Snappy submodules. The `no-fasttest` tag is removed from 259 tests that pass in this configuration. Closes: #126408 Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Workflow [PR], commit [7f7fcad] Summary: ✅
AI ReviewSummaryThis PR removes the Apache Arrow C++ dependency from the native Final VerdictStatus: ✅ Approve |
- Snappy needs crc32c, so check out the `crc32c` submodule in the fast test as well. - Use a range-based loop in `RLEEncoder` (`modernize-loop-convert`). - Keep `no-fasttest` on `05243_query_condition_cache_top_k_parquet`: it enables a fail point. CI report: https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=126477&sha=b74dad691ba426a68510da00db969379ad2b7a2c&name_0=PR PR: #126477 Co-Authored-By: Claude Opus 5.5 <[email protected]>
…` encoder An empty `String` value may have a null pointer, which UBSan reports as `null pointer passed as argument 2, which is declared to never be null` in `encodePlain`. https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=126477&sha=5576f72ac297b7b9d4935eb80249d39f0fcdbba6&name_0=PR&name_1=Stateless%20tests%20%28arm_asan_ubsan%2C%20targeted%29 #126477 Co-Authored-By: Claude Opus 5.5 <[email protected]>
…packBits` `DELTA_BINARY_PACKED` pages of uncompressed column chunks can point directly into a page cache cell served by the zero-copy path of `Prefetcher`, which is not padded. `unpackBits` now takes the end of the input and unpacks the last values, whose 9-byte loads would cross it, from a zero-padded copy of the tail. A zero bit width no longer loads anything. #126477 (comment) Co-Authored-By: Claude Opus 5.5 <[email protected]>
# Conflicts: # ci/jobs/fast_test.py # src/Processors/Formats/Impl/Parquet/Reader.cpp
The pages can be pruned by different threads, so `--print-profile-events` may report the profile event in several increments (`1` and `1` instead of `2`), which made the test fail in the flaky check. https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=126477&sha=latest&name_0=PR&name_1=Stateless%20tests%20(amd_binary%2C%20flaky%20check) #126477 Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
🕵 @groeneai, investigate the failures: |
|
Both are already fixed by merged PRs of mine, which landed after these runs (the workflow for 03fa603 was created 2026-10-18 16:49 UTC):
CIDB has 0 failures of either test on builds that contain the fix (master since then: 0 in 1193 and 919 runs). Every later failing row is a master commit behind the fix or a re-run of a workflow created before it. A re-run reuses the old merge commit, so this PR picks up both fixes with its next push. |
Build profile diff (arm_release)Comparing Binary sizes
The official master build is compiled with Object file sizes
|
| Object file | Master | PR | Δ |
|---|---|---|---|
contrib/arrow-cmake/CMakeFiles/_parquet_format.dir/__/arrow/cpp/src/generated/parquet_types.cpp.o |
new | 528.30 KiB | +528.30 KiB |
contrib/thrift-cmake/CMakeFiles/_thrift_minimal.dir/__/thrift/lib/cpp/src/thrift/transport/TBufferT… |
new | 82.29 KiB | +82.29 KiB |
src/CMakeFiles/dbms.dir/Processors/Formats/Impl/Parquet/Write.cpp.o |
1.45 MiB | 1.51 MiB | +59.91 KiB (+4.04%) |
contrib/thrift-cmake/CMakeFiles/_thrift_minimal.dir/__/thrift/lib/cpp/src/thrift/protocol/TProtocol… |
new | 37.64 KiB | +37.64 KiB |
src/CMakeFiles/dbms.dir/Processors/Formats/Impl/Parquet/Decoding.cpp.o |
427.13 KiB | 450.67 KiB | +23.54 KiB (+5.51%) |
src/CMakeFiles/dbms.dir/Processors/Formats/Impl/Parquet/ALPEncoding.cpp.o |
222.07 KiB | 199.19 KiB | -22.88 KiB (-10.30%) |
contrib/thrift-cmake/CMakeFiles/_thrift_minimal.dir/__/thrift/lib/cpp/src/thrift/TOutput.cpp.o |
new | 22.78 KiB | +22.78 KiB |
717 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.
Slowest function optimization changes (ThinLTO)
Median per-function time ratio to the master baseline: programs/clickhouse ×0.63, programs/clickhouse-keeper ×0.66 (each binary is linked separately, on a different machine and with different build flags); deltas below are relative to it.
| Binary | Function | Master | PR | Δ vs median |
|---|---|---|---|---|
programs/clickhouse |
DB::registerFunctionConversion(DB::FunctionFactory&) |
5.6 s | 11.9 s | +8.5 s (+243%) |
programs/clickhouse |
_ZN6detail10static_forITk7is_enumN2DB23AttributeUnderlyingTypeEZNS1_29callOnDictionaryAttributeType… |
3.3 s | 7.3 s | +5.2 s (+252%) |
Compile time of recompiled translation units
30 translation units recompiled, 268 s compile time in total, 24 of them have a recent master baseline.
…out-arrow Port the accumulation of `GeospatialStatistics` for `GEOMETRY` columns in the native writer from `parquet::geospatial::GeoStatistics` of Arrow to a self-contained WKB bounder, because the native Parquet writer no longer depends on Arrow.
Use `const uint8_t *` instead of `const UInt8 *` (which is `char8_t`) to match `ByteArray::ptr`, and initialize local variables to satisfy clang-tidy. https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=126477&sha=ab4bd4b0dc94d5ea31bc0c139a8f9522a5b5a5c3&name_0=PR&name_1=Fast%20test #126477 Co-Authored-By: Claude Opus 5.5 <[email protected]>
…out-arrow Master added the `ALP` encoding of Parquet (#125135), whose writer was an adapter to `parquet::TypedEncoder` and whose reader used `arrow::internal::unpack`. Reconcile it with the native writer of this branch: - `ALPEncoder` now has the same interface as `PlainEncoder` and `DictionaryEncoder` (`put`, `estimatedDataEncodedSize`, `flush`), and `lastPageEncoding` instead of `encoding`. - The `ALP` decoder uses the native `unpackBits`, which is now declared in `Decoding.h`. - Test `04708_functions_to_subcolumns_file_storages`: keep both the removal of the `no-fasttest` tag (this branch) and of `SET enable_analyzer` (master).
…rrent miniblock The size of a miniblock in bytes, `values_per_block / miniblocks_per_block * bit_width / 8`, was computed in `size_t` from an unchecked header and could wrap. With a block of 2^61 values and bit width 64 it became 0, the miniblock kept its full value count, and `unpackBits`, bounded only by the end of the page, unpacked the deltas from the rest of the page and from its stack tail buffer past the input instead of rejecting the page. The decoder based on `arrow::bit_util::BitReader` was bounded by the miniblock and did not read past it. Now `nextMiniblock` compares the value count with the available bytes in values, so the size cannot overflow, and `unpackBits` is bounded by the end of the miniblock. The new test `05459_parquet_delta_binary_packed_miniblock_overflow` reads a hand-crafted file with such a header: without the fix it returns 200 garbage values, with the fix (and on master) it throws `ATTEMPT_TO_READ_AFTER_EOF`. The file is excluded from `00900_long_parquet_load_2`, like the other malformed fixtures. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…out-arrow # Conflicts: # src/Processors/Formats/Impl/Parquet/Decoding.cpp # tests/queries/0_stateless/00900_long_parquet_load_2.sh
…out-arrow Master replaced the `apache/orc` library with a native ORC reader and writer, so the `ENABLE_ORC` option and the `orc_proto` generation that this branch kept in `contrib/arrow-cmake` are gone; `USE_ORC` follows master. The Arrow helper headers keep this branch's `USE_ARROW_LIBRARY` guard.
When a filter was applied inside `DeltaBinaryPackedDecoder::decode` and the converter was not trivial (for example, `INT32` with the converted type `INT_8`), the kept values were decoded into `temp_values` before conversion, and the filtered-out values were decoded into `temp_values.data()` as well. Every filtered-out value after a kept one overwrote the first kept value, so `PREWHERE` returned wrong values, e.g. `[1,4,6,8]` instead of `[1,3,5,7]`. Filtered-out values now go to a separate scratch value. Found in the review of ClickHouse#126477 Co-Authored-By: Claude Opus 5.5 <[email protected]>
# Conflicts: # src/Processors/Formats/Impl/Parquet/Decoding.cpp
|
Read-side numbers for the Change in query time at 16 threads (10 paired runs per query, geometric mean with 95% CI), ClickBench queries over 10M rows, on AWS r7g.4xlarge (Graviton3) and r6i.8xlarge (Xeon Platinum 8375C, pinned to 16 cores):
Baseline times are 90-230 ms. CPU time ( For all 43 ClickBench queries, the full result before Files without page CRCs, such as the published ClickBench Parquet files, are not affected. ReproductionData: the first 10 files of the partitioned ClickBench dataset, rewritten by ClickHouse: -- hits_{0..9}.parquet from https://datasets.clickhouse.com/hits_compatible/athena_partitioned/
INSERT INTO FUNCTION file('hits_crc.parquet', Parquet)
SELECT * FROM file('hits_{0..9}.parquet', Parquet)
SETTINGS output_format_parquet_compression_method = 'snappy', output_format_parquet_write_checksums = 1;Table: taskset -c 0-15 clickhouse local --tmp --time --max_threads=16 --max_parsing_threads=16 \
--query="$(cat create.sql); $QUERY" |
# Conflicts: # src/Processors/Formats/Impl/Parquet/Decoding.cpp
…lock size bound from master Master bounded the `DELTA_BINARY_PACKED` block size, so the corrupted page of this test is now rejected in the header with `INCORRECT_DATA` instead of `ATTEMPT_TO_READ_AFTER_EOF` in `unpackBits`. Also drop the mention of `BitReader::GetBatch` from the comment: the native decoder does not use it. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
🕵 Thanks, @snelheidai, for measuring the read side of the |
|
🕵 The only red check on f5730ab was |
# Conflicts: # src/Processors/Formats/Impl/Parquet/Decoding.cpp # src/Storages/ObjectStorage/DataLakes/DeltaLakeMetadata.cpp
…out-arrow Resolve conflicts with the migration of `src/Processors/Formats` to `-WithMemoryTracking` containers: keep the Arrow-free `parq::SchemaElement` interfaces of this branch and use `VectorWithMemoryTracking` as master does. Also use `SetWithMemoryTracking` in `StatisticsGeometry` and mark the thrift setter argument with `STYLE_CHECK_ALLOW_STD_CONTAINERS` to pass the style check. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
🕵 The only red check on 0651104 was |
…out-arrow Resolve the conflict in `ArrowBufferedStreams.cpp`: keep the explicit `Formats/FormatSettings.h` include from master and the `USE_ARROW_LIBRARY` guard from this branch. Also guard the new `gtest_ch_column_to_arrow_column_record_batch_split.cpp` with `USE_ARROW_LIBRARY`, because `CHColumnToArrowColumn` is only built with the Arrow library now. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…e fast test ClickHouse#126477 builds Parquet in the fast test and removed `no-fasttest` from 03548, so the cases this PR added to it ran there and failed: the fast test has neither pyarrow nor the IcebergLocal engine. They now live in 03548_parquet_missing_tuple_elements_pyarrow_iceberg, tagged `no-fasttest`; the cases that only use files written by ClickHouse stay in 03548 and keep running in the fast test. The moved cases and their expected output are unchanged. Co-Authored-By: Claude Opus 5.5 <[email protected]>
The native Parquet reader and writer called a few functions of Apache Arrow and parquet-cpp, so
USE_PARQUETrequired the whole Arrow C++ library, and Parquet was disabled in the fast test (-DENABLE_LIBRARIES=0), which also runs in the merge queue. Hundreds of stateless tests were taggedno-fasttestonly because of Parquet or Arrow, which is how #124131 passed the merge queue.Now native Parquet depends only on the structures generated from
parquet.thriftand a minimal Thrift runtime:ch_contrib::parquet_format:parquet_types.cppwithch_contrib::thrift_minimal(five Thrift runtime files to (de)serialize structures in memory, no networking, no OpenSSL). The generated header is exposed from its own include directory, so the native code cannot include Arrow headers by accident.DELTA_BINARY_PACKEDand decoding ofBYTE_STREAM_SPLIT(instead ofarrow::bit_util::BitReaderandByteStreamSplitDecode).arrow::internal::crc32).parq::SchemaElementandXXH64(instead ofparquet::ColumnDescriptorandparquet::XxHasher); the eligibility rules for logical and converted types are the same.PLAINand dictionary encoders and the RLE / bit-packed hybrid encoder in the writer (instead ofparquet::MakeTypedEncoderandRleBitPackedEncoder). The RLE encoder follows the same run-splitting rules, and the dictionary keeps the first-occurrence order, so the written files are byte-identical to master (checked on a file with dictionary, fallback, nullable, array, boolean, andFixedStringcolumns: the only difference is the build hash increated_by).Build flags:
USE_PARQUET: the native reader and writer, needs onlych_contrib::parquet_format.USE_ARROW: the nativeArrow/ArrowStreamformats, needs only the FlatBuffers-generated IPC bindings, no longer tied to parquet-cpp.USE_ARROW_LIBRARY(new, CMake optionENABLE_ARROW_LIBRARY, defaultENABLE_LIBRARIES): the Apache Arrow C++ library with parquet-cpp. Still needed for Hive, Arrow Flight, delta-kernel-rs (it passes data through the Arrow C data interface), the Arrow column converters, and theParquetMetadataformat, which is not rewritten here.The fast test builds with
-DENABLE_PARQUET=1and checks out thearrow,thrift,flatbuffers, andsnappysubmodules. The binary has no Arrow C++ symbols (only the FlatBuffers IPC bindings).Tests:
no-fasttesttag is removed from 259 tests, selected by running all 624 tagged tests that mention Parquet or Arrow against a build with the fast-test CMake flags and the fast-test server config. Tests that usepyarrow(not in the fast-test image),ParquetMetadata, ORC, Avro, Iceberg, Delta Lake, or S3 keep the tag.gtest_write_parquet_page_index) pass.05406_parquet_native_encoderscovers round trips throughPLAIN, dictionary, and dictionary-to-PLAINfallback for all physical types, levels of nested columns, and keeping0/-0and NaN payloads apart in the dictionary.Performance (single thread, CPU time, best of 5, aarch64, compared with a master build):
DELTA_BINARY_PACKEDandBYTE_STREAM_SPLITcolumns written by pyarrow: the same (within noise), identical results.FixedString, booleans, high-cardinality integers that fall back toPLAIN, nullable and array columns).Follow-ups: rewrite the
ParquetMetadataformat onparq::structures (about 16 more tests could then run in the fast test), and remove the Arrow C++ library entirely.Closes: #126408
Related: #124131
Related: #126406
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
The native Parquet reader and writer no longer depend on the Apache Arrow C++ library: a build with Parquet needs only the Thrift-generated Parquet structures. A new CMake option
ENABLE_ARROW_LIBRARYcontrols the Arrow C++ library, which is still used by Hive, Arrow Flight, delta-kernel-rs, and theParquetMetadataformat. Parquet is now tested in the fast test.🤖 Generated with Claude Code
Workflow [PR]
Sync PR [sync-upstream/pr/126477]
Version info
26.11.1.1996-master(included in26.11and later)