Repository navigation
Read and write Vortex without the Apache Arrow C++ library - #131773
Conversation
The Vortex library exchanges data with ClickHouse through the Arrow C data interface. Chunks were imported with `arrow::ImportRecordBatch` and converted with `ArrowColumnToCHColumn`, and written with `CHColumnToArrowColumn` and Arrow's C bridge. Now they go through the native Arrow IPC code: - `ArrowIPC::importSchemaFromC` turns a C schema into the IPC `Schema` the native reader parses, and `importRecordBatchFromC` decodes a C array with `RecordBatchDecoder` without copying its buffers: a new `RecordBatchDecoder::decodeExternalBatch` takes the field nodes and the buffers directly. Arrays with an offset are sliced, and their bitmaps re-packed. - `ArrowIPC::buildChunk` (the conversion of the native `Arrow` format to the header) and `ArrowIPC::inferColumns` (its schema inference) are shared with Vortex. - Writing uses the exporter of the Delta Lake writes, with three new choices of the native writer that Vortex needs (`FixedString` as `Binary`, `DateTime` as a timestamp, `Nothing` as `Null`). - The filter pushdown and the scan planner use the Arrow-free schema description, and the file is read through a small `Vortex::VortexFile` instead of an Arrow `RandomAccessFile`. `USE_VORTEX` no longer needs the Arrow library. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…lease only what the library does not take - arrow-rs requires the buffers it imports to be aligned to their values (16 bytes for 128-bit integers), while the IPC body aligns them to 8 bytes: the exporter copies a buffer that is not aligned to 16 bytes. - The C array exporter never compresses the buffers. - `vortex_ffi_writer_create` and `vortex_ffi_writer_write` move the schema and the array out without marking ours released, so they are released only when an exception comes before the call. - The types of Vortex files are inferred as the Arrow library reader inferred them under `schema_inference_make_columns_nullable = 1`: the elements of a nullable struct keep their nullability. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Workflow [PR], commit [63de5bb] Summary: ✅
AI ReviewSummaryThe PR routes The decoded-column consumers are covered: Missing context / blind spots
Final VerdictStatus: ✅ Approve |
Resolved conflicts: kept both the `Nothing` as `Null` and the `Variant` as JSON text branches in `RecordBatchEncoder::encodeField`; kept the Arrow-free types with master's `[[nodiscard]]` in `VortexExpressionConverter.h`.
… Vortex schema inference `RecordBatchDecoder` returns constants for `Null` fields and bufferless structs, while `ArrowIPC::buildChunk` expects full columns, as the `Arrow` input format provides them. Reading such a field as another type, e.g. `Nullable(UInt64)`, hit an `assert_cast` on the constant column. Materialize the decoded columns of each piece before building the chunk. With `schema_inference_make_columns_nullable = 0`, remove `Nullable` at every depth of the inferred types (except around `Nothing`), as the Apache Arrow library reader did, via the same helper that the `Arrow` format schema reader uses. Co-Authored-By: Claude Opus 5.5 <[email protected]>
`ArrayBuilder::nextBuffer` copies a buffer that is not aligned to 16 bytes into a `PODArray`, but a small allocation is aligned only to its size: an 8-byte buffer (e.g. the offsets of a one-row batch) got an 8-aligned copy, and the `chassert` failed in debug builds on `05339_vortex_iceberg_mixed_write_format` and on Delta Lake writes. Request the 16-byte alignment from the allocator. CI report: https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=131773&sha=789ecd0e04f23b379c14e1c41c14f4ec29525d48&name_0=PR&name_1=Stateless%20tests%20%28amd_debug%2C%20parallel%29 PR: #131773 Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
🕵 Merged @groeneai, investigate the failure of the |
|
The fix is #129675 (mine, open). In this run (job log) all 8 readiness probes to the CI logs cluster ended |
…schema `master` added `VortexExpressionConverter::convertEmpty`, which took the type of the column from an `arrow::Field`. After merging it into this branch the type comes from `ArrowIPC::ArrowField`, like in the other conversions. Co-Authored-By: Claude Fable 5.2 <[email protected]>
Fixes `modernize-use-nodiscard` in the `arm_tidy` build: https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=131773&sha=aad786e74769c9c9be3db1676a0e4a41e53cb3a8&name_0=PR&name_1=Build%20%28arm_tidy%2C%202%2F4%29 #131773 Co-Authored-By: Claude Fable 5.2 <[email protected]>
`vortex_ffi_scan_create` returned a live scan, but the member `scan` was assigned only after `ArrowIPC::importSchemaFromC`, which allocates and can throw. In that case `closeReader` found no scan to cancel and free, and the handle leaked. Now the member is assigned right after the scan is created. Co-Authored-By: Claude Fable 5.2 <[email protected]>
|
🕵 Merged Checked locally: the build, Thanks for the pointer to #129675 for the |
Build profile diff (arm_release)Comparing ✅ No significant changes. Binary sizes
The official master build is compiled with Object file sizes491 object files changed (+237.57 KiB total), 0 added.
716 more object files are built by the master warmup baseline only (it builds every object-file target, a pull request build only Compile time of recompiled translation units811 translation units recompiled, 4644 s compile time in total, 811 of them have a recent master baseline. |
|
📊 Cloud Performance Report ✅ AI verdict: This PR found no performance changes caused by the PR. It only changes the Arrow format and Vortex file-reading code, plus the build setting that switches Vortex on and new tests; none of the ClickBench or TPC-H queries read or write those formats. The only flagged query, ClickBench Q31 (a GROUP BY on WatchID and ClientIP, 215 ms to 251 ms, +16.7%), stays inside master's recent range of 202–258 ms and is often unstable on master. The automated decision to leave it as inconclusive matches the code changes. clickbenchFlagged queries (1 of 43)
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. tpch_adapted_1_official🟢 No significant changes Debug info
|
…w` settings `getArrowFormatSettings` of the Vortex writer now starts from the default `output_format_arrow_*` settings, so `output_format_arrow_date_as_uint16` (enabled by older `compatibility` values) no longer turns a `Date` into a number. Test `05839_vortex_date_ignores_arrow_settings` checks both cases; its reference is the output of the build before this PR. Also copy under-aligned buffers of the exported `ArrowArray` into a `Memory` with 16-byte alignment: `PODArray` does not guarantee the alignment of its data, which failed the assertion in debug builds (`05830_vortex_null_columns_and_non_nullable_inference`). Co-Authored-By: Claude Opus 5.5 <[email protected]>
Part of removing the Apache Arrow C++ library: the
Vortexformat no longer uses it.The Vortex library exchanges data with ClickHouse through the Arrow C data interface. Chunks were imported with
arrow::ImportRecordBatchandArrowColumnToCHColumn, and written withCHColumnToArrowColumnand Arrow's C bridge. Now both directions go through the native Arrow IPC code of theArrowformat.Import:
ArrowIPC::importSchemaFromCturns a C schema into the IPCSchemaFlatBuffer and parses it with the nativeparseSchema, so all of its validation applies.ArrowIPC::importRecordBatchFromCdecodes a C array withRecordBatchDecoderwithout copying its buffers, via a newRecordBatchDecoder::decodeExternalBatchthat takes the pre-ordered field nodes and buffer slices directly. The C data interface lets an array (and, for structs, fixed-size lists and sparse unions, its children) start at an offset: buffers are sliced accordingly, and bitmaps not starting at a byte boundary are re-packed.ArrowIPC::buildChunk(the conversion of decoded columns to the header, from theArrowinput format) is shared with Vortex.Export uses the exporter of #131768 (this PR includes it). It gains three writer choices that Vortex needs and the
Arrowformat does not use:FixedStringasBinary,DateTimeas a timestamp in seconds, andNothingasNull. Buffers that are not aligned to 16 bytes are copied, because arrow-rs checks the alignment of 128-bit values.The filter pushdown and the scan planner use the Arrow-free schema description. The file is read through a small
Vortex::VortexFileinstead of an ArrowRandomAccessFile. Schema inference keeps the old behavior.USE_VORTEXno longer needs the Arrow library.Tested locally:
Arrow/ArrowStream(246 tests) pass, except those that also fail with a master build in my environment (S3, schema registry, missingtest.hits, etc.);Related: #131768
Changelog category (leave one):
🤖 Generated with Claude Code
Workflow [PR]
Sync PR [sync-upstream/pr/131773]
Version info
26.12.1.221-master(included in26.12and later)