Repository navigation
Support the Vortex file format - #112950
Conversation
Add `Vortex` input and output formats for reading and writing Vortex files (https://github.com/vortex-data/vortex), an extensible columnar file format for compressed Apache Arrow-compatible data. The implementation uses the Rust `vortex` crate through a new C FFI crate `rust/workspace/vortex` (`_ch_rust_vortex`). Data crosses the FFI boundary through the Arrow C Data Interface and is converted with the same `ArrowColumnToCHColumn`/`CHColumnToArrowColumn` code as the `Arrow` format. IO is delegated back to ClickHouse through callbacks, so reads go through ClickHouse's own buffers (with range reads for seekable inputs and whole-file buffering otherwise), and writes stream into the output buffer. All work is driven by a single-threaded runtime on the calling thread: the library spawns no threads. The reader supports projection pushdown (only the requested columns are read), count-only queries from file metadata, and schema inference. The writer uses the library's default adaptive compression (BtrBlocks-style cascading encodings plus zstd). Closes #87327 Co-Authored-By: Claude Fable 5 <[email protected]>
|
Preview deployment for your docs. Learn more about Mintlify Previews.
|
|
Workflow [PR], commit [9f8f660] Summary: ✅
AI ReviewSummaryThe PR adds Findings
Tests
Final VerdictStatus: |
# Conflicts: # src/Formats/registerFormats.cpp
Address the AI review of #112950 and the `arm_tidy` build failure. - `VortexBlockInputFormat::prepareReader` pruned the scanned columns to the exact top-level names of the requested header. A header column addressing a subcolumn, such as `t.a`, dropped the parent field `t` from the scan, and `ArrowColumnToCHColumn` then silently filled the column with default values. Keep `Nested::extractTableName` of every header column, the same way the `ArrowIPC` reader does. Covered by a new case in `04669_vortex_format`. - `VortexBlockOutputFormat` did not override `resetFormatterImpl`, so a formatter reused by `MessageQueueSink` kept the finished Rust writer and the next message failed with `writer is already finished`. Free the writer and the conversion state on reset, like `Arrow`, `ORC`, and `Parquet` do. - Value-initialize the `ArrowArray` and `ArrowSchema` C structures, fixing the `cppcoreguidelines-pro-type-member-init` errors in `Build (arm_tidy)`: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=112950&sha=d4debff97a3088dde960cc32e1d0ce8af1c997b6&name_0=PR&name_1=Build%20%28arm_tidy%29
The MSan build failed to link unit_tests_dbms with relocation R_X86_64_PC32 out of range errors: the MSan-instrumented Vortex Rust library (with origin tracking) adds so much code that the binary exceeds the 2 GiB range of the small code model. Disable Vortex under MSan, following the precedent of wasmtime and delta-kernel-rs. Consequently, exclude Vortex from the format enumeration in 02187_async_inserts_all_formats (its availability now varies by build, so it cannot appear in the static reference; this also fixes the reference mismatch this PR introduced there), and tag 04669_vortex_format with no-msan. CI: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=112950&sha=645a6771def9e396863d6401ca67230109b220dd Co-Authored-By: Claude Fable 5 <[email protected]>
Master removed the legacy Docusaurus tree (docs/en), which conflicted with the Vortex doc added there. The Vortex format page is ported to the Mintlify tree: docs/reference/formats/Vortex.mdx (body matches the embedded documentation registered via FormatFactory::setDocumentation), a row in docs/reference/formats/index.mdx, and an entry in docs/reference/navigation.json.
|
🕵 @groeneai, investigate the two
Both hangs are unrelated to this PR: the hung queries do not involve the |
|
Both hangs are the same defect, and it is not the one the
and its stack ( The So both rows are Cost vs interruptibility are two separate things, and only the first has a fix. Cost: your #113140 is the right fix for it, and the Interruptibility: #113140 does not address it. Its 87 added lines contain no cancellation check (0 occurrences of The phase counters confirm the hang is in the still-running phase rather than anything already finished: recorded phases sum to 6.6 s of 1757 s ( I am authoring the cancellation-checkpoint fix and will link the PR here when it opens. #112203 is a different mechanism (uninterruptible evaluation of one large value); this is uninterruptible plan construction, closer to #113003 and covered in general by #47272. Unrelated to this PR, confirmed rather than assumed. Your MSan argument holds: |
The `Vortex` output format inherited the generic `CHColumnToArrowColumn` mapping that serializes `DateTime` as plain Arrow `UINT32`, so the temporal type was silently lost on round-trip: `DESC file(...)` of a written file inferred `UInt32`. Add an `output_datetime_as_timestamp` setting to `CHColumnToArrowColumn` (following the existing `output_date_as_uint16` pattern) that exports `DateTime` as Arrow `TIMESTAMP` with second precision and the column's time zone, and enable it for `Vortex`. Such files are read back as `DateTime64(0)`. `Arrow` and `Parquet` keep the old behavior. Update the format documentation accordingly and add a test with schema-inferred readback of `DateTime`, including `Nullable` and `Array` nesting. Co-Authored-By: Claude Fable 5 <[email protected]>
|
Fixing PR for the I had a fix for this on a local branch, but @alexey-milovidov opened #113415 with the identical |
…ex` format Vortex has no type for IP addresses, so `IPv4` columns are written through the generic Arrow `UINT32` carrier (the same as in `Parquet` and `Arrow`), and schema inference reads them back as `UInt32`. Document this explicitly, including the explicit-schema way to read the column back as `IPv4`, and add a stateless test covering inference, both round trips, and the documented `IPv6` write rejection. Co-Authored-By: Claude Fable 5 <[email protected]>
|
🕵 CI triage for the reds on
|
|
The AST fuzzer STID 2270-2caa failure on I confirmed that on your exact query rather than by inference. A pre-fix binary reproduces your log line byte for byte ( Mechanism: The crash is the visible half. When no constant survives there is no error and rows are silently dropped instead: over two shards of 1000 rows,
113469 covers this carrier; I am not claiming it clears the whole message class. Agreed that 96656 and 103695 are the same family with different stack IDs. One caveat on keying: within this family a single STID pools more than one query shape, so the shape identifies a carrier more reliably than the STID does. |
# Conflicts: # src/Common/ProfileEvents.cpp # src/Storages/ObjectStorage/DataLakes/Iceberg/Compaction.cpp
…e row
`Set::execute` converts the column to the type of the set keys, and a comparison
with a `FixedString` constant pads the other side with zeros. Neither conversion
is injective, so the filter pushed into the Vortex scan, which converts the
constant to the column type and compares raw values, dropped rows that the final
filter would keep: a `String` `'a'` against a `FixedString(2)` key, a `UInt8` `2`
against a `Bool` key, a `DateTime64` at noon against a `Date` key, and `s =
toFixedString('a', 2)`.
`convertIn` now pushes only keys of the column's own type, and integer keys for
an integer column (converted exactly or not at all). `Bool` is checked apart
because it `equals` `UInt8`. `convertComparison` does not push `FixedString`
constants, nor non-string constants against a `String` column.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
The list of values `defer_drop` keeps for `drop_deferred` was process-wide, so the exit guard of an FFI call of one query could free the tasks and buffers that another query's teardown deferred. ClickHouse accounts the memory a thread frees to the query it runs, so the wrong query was credited. The list is thread-local now, and `vortex_ffi_scan_release`, which can wake a task of a runtime that is gone, drops what it deferred on exit as well. Co-Authored-By: Claude Opus 5.5 <[email protected]>
# Conflicts: # src/Common/ProfileEvents.cpp
With `max_parsing_threads = 1` the `Vortex` reader runs its tasks inside `read`. A `Parquet` reader that initialized the shared resources of an Iceberg snapshot first still sets up a download pool, and the `Vortex` reader scheduled its reads there. Once a pool thread took a read out of the queue, `read` saw both queues empty and threw `Deadlock in the Vortex reader (single-threaded)` while the read was still in flight. `hasSeparateIORunner` is now false without a parsing pool, so all tasks stay inline. The new test reproduces the exception reliably without the fix. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Writing the 1M-row file dominated the test, which ran at about 175 s in `Stateless tests (amd_tsan, flaky check)` and sometimes went over the 180 s limit. 400k rows still make 8 splits. https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=112950&sha=13ce1af69edab73b8ed369953b362983691c84b6&name_0=PR&name_1=Stateless%20tests%20%28amd_tsan%2C%20flaky%20check%29 PR: #112950 Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
…AzureQueue` The queue sources call `StorageObjectStorageSource::createReader` without a `FormatFilterInfo`, so nothing set `need_row_numbers`, and the Parquet reader stopped attaching `ChunkInfoRowNumbers`: `_row_number` was read as NULL. Ask for row numbers at the shared `createReader` boundary whenever a row-dependent virtual column is requested, as is already done for files with attached deletes. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…conversions A file `String` column read as `Nullable(UInt64)` turns a malformed string into NULL after the scan, while a pushed `IS NULL` / `isNotNull` sees the original non-null string and dropped the row. Push a null check only when the types match, the header is `String`, or an integer is read as another integer. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…n builds `oneshot` 0.2 gives `.await` an `AsyncReceiver` future rather than `Receiver`. Its `poll` reads the payload behind the same standalone `fence(Acquire)` that `rustc` does not report to ThreadSanitizer, so the existing `Receiver*::poll` entry no longer matched the inlined `take_message`. The flaky check failed `05331_vortex_lazy_materialization_object_storage`, `04821_vortex_filter_pushdown` and `04927_vortex_parallel_read` on it. https://s3.amazonaws.com/clickhouse-test-reports/PRs/112950/9bc143e56853b7b122d17053abc6fa996ff22a93/pr/result_stateless_tests_amd_tsan_flaky_check.json #112950 Co-Authored-By: Claude Opus 5.5 <[email protected]>
…arses them `tryConvertFieldToTypeExact` parsed a string constant with default `FormatSettings`, while `FunctionComparison` uses `cast_string_to_date_time_mode`: `best_effort` reads `'20200101'` as 2020-01-01, the default parsing as Unix seconds. The pushed literal then dropped rows that ClickHouse would have matched. A string constant compared with a column of another type is now converted with the `ComparisonParams`-equivalent settings derived from the query context, and not pushed when that conversion fails. Co-Authored-By: Claude Opus 5.5 <[email protected]>
# Conflicts: # src/Common/ProfileEvents.cpp
…oral columns `'20200101'` compared with a `DateTime` / `DateTime64` column has to match the same rows with and without `input_format_vortex_filter_push_down`, under both `cast_string_to_date_time_mode` values. Co-Authored-By: Claude Opus 5.5 <[email protected]>
| } | ||
|
|
||
| fn make_session(runtime: &Arc<HostRuntime>) -> VortexSession { | ||
| VortexSession::default().with_handle(runtime.handle()) |
There was a problem hiding this comment.
[P2] Enforce the query memory budget during Rust decoding
This session retains Vortex's default allocator, and CallbackReader::read_at likewise allocates its buffer directly with ByteBufferMut::with_capacity_aligned. Those Rust system allocations reach ClickHouse's C allocation wrappers, which call Memory::trackMemoryFromC → CurrentMemoryTracker::allocNoThrow: they charge memory but do not reject an allocation that exceeds max_memory_usage. No throwing budget check is installed before execute_arrow materializes the decoded batch.
Consequently, a single row holding a large, compressible Array(UInt64) can allocate far beyond the query budget before onChunk reaches the first throwing ClickHouse-column allocation. Limiting the number of splits and the compressed read size does not bound the decoded allocation; an eventual MEMORY_LIMIT_EXCEEDED happens after that memory has already been obtained. The sibling ArrowMemoryPool::Allocate explicitly uses a throwing ClickHouse allocator to avoid this problem.
Please provide a budget-enforcing allocation/check boundary for Rust read/decode buffers (Vortex exposes a session HostAllocator) and a focused low-memory-limit regression demonstrating that a large compressed split fails before allocating its decoded size. This concern follows from the allocation paths; the peak-memory effect has not been reproduced locally.
There was a problem hiding this comment.
🕵 Not changed in this PR, because a session HostAllocator would not give the bound you describe. In vortex-array 0.84.0, HostAllocator is only consulted at a handful of call sites (executor.rs, chunked canonicalization, variant_get, open.rs). The decode paths that would blow up on a compressible Array(UInt64) (builders, BufferMut::with_capacity, the run-end/constant/FSST decompressors) allocate through the global Rust allocator. That allocator cannot report an over-budget allocation either: a C++ exception must not unwind through Rust frames, and Rust aborts the process on a failed allocation, so returning null from malloc on the limit would turn a MEMORY_LIMIT_EXCEEDED into a server abort.
The allocations do run on ClickHouse threads (the runnables are driven by our task queues), so they are charged to the query's MemoryTracker, and the query fails at the next throwing ClickHouse allocation. The overshoot is bounded by what one split decodes. A real budget-enforcing boundary needs fallible allocation in the decoders upstream, or a per-split decoded-size estimate checked before execute_arrow. I'd rather do either as a follow-up than ship a partial HostAllocator that suggests a bound it doesn't provide. Leaving this thread open for that.
… pushed into a Vortex scan Vortex compares floating-point values in their total order and bitwise: `-0.0` is less than `+0.0` and `NaN` is greater (or, negative, less) than every number. ClickHouse compares as IEEE 754 does. A pushed `f = 0` therefore dropped a `-0.0` row, and `NOT (f > 1)` dropped a positive `NaN` row, before the final filter could see them. Now an equality with zero matches both zeros, a range bound at zero is taken on the side that includes both, and a range comparison - which still lets `NaN` through, a widening - is not pushed where the condition has to be exact, under `NOT`. A zero key of `IN` is matched as both zeros, and not pushed when the set is negated or the position has to be exact. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
🕵 @groeneai, investigate the failure: https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=112950&sha=a96507265ec054a54f037bb5dc901b371a7b9e24&name_0=PR&name_1=BuzzHouse%20%28arm_asan_ubsan%29 ( The other red jobs on this PR don't touch the Vortex code either:
|
|
The fix is already in progress: #117399 (mine, open, CI green on c46bb15). The worker was freed by |
|
🕵 Merged The red jobs on 1239859 are unrelated to Vortex:
@groeneai, thanks for linking #117399 for the The five open review threads already have replies. Each one is waiting on a follow-up PR or a maintainer decision: Vortex extension dtypes, bulk string copy for view arrays, the MSan size limit / C++ rewrite, exact vs widened filter pushdown, and a memory-budget boundary for Rust decoding. |
Closes: #87327
Related: ClickHouse/rust_vendor#74
Related: ClickHouse/rust_vendor#79
Related: #115096
Related: #114373
Related: #116021
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Added support for reading and writing the Vortex columnar file format (the
Vortexinput and output format). This closes #87327.Documentation entry for user-facing changes
The implementation uses the Rust
vortexcrate (v0.84.0) through a new C FFI craterust/workspace/vortex(_ch_rust_vortex), following the same pattern asprqlandpolyglot. Data crosses the FFI boundary through the Arrow C Data Interface and is converted with the sameArrowColumnToCHColumn/CHColumnToArrowColumncode as theArrowformat. IO is delegated back to ClickHouse through callbacks: reads go through ClickHouse's own read buffers (range reads for seekable inputs, whole-file buffering otherwise), and the produced file is streamed into the output buffer. The library spawns no threads of its own: a scan is split into tasks that ClickHouse runs on its own thread pools (max_parsing_threadsfor decoding,max_download_threadsfor reads), writing is driven on the calling thread, and Rust panics are caught at the FFI boundary and turned into exceptions.Features:
input_format_vortex_preserve_orderis set.count()-only queries answered from file metadata without reading data.Limitations (documented in
docs/reference/formats/Vortex.mdx):Map,Int128/UInt128/Int256/UInt256,IPv6, andIntervalcolumns cannot be written (no corresponding Vortex type).StringandFixedStringare written as VortexBinary(ClickHouse strings are arbitrary bytes, while Vortex requiresUtf8to be valid UTF-8).unit_tests_dbmsoverflows the 2 GiBR_X86_64_PC32relocation range (same approach aswasmtimeanddelta-kernel-rs).Parquet— parallelism can be added later. Reading is parallel since feat: parallel reading for vortex #115096 was merged into this PR: on ClickBench, reads went from geomean ~26.8x slower thanParquetto ~1.2x, winning 9 of 43 queries (see the benchmark results). Filter pushdown (added in Enhancement for Vortex format #114373,input_format_vortex_filter_push_down, on by default) lets the scan skip the statistics zones the predicate rules out and decode only the matching rows of the rest: on a file of 1 000 000 sorted values,WHERE n = 500000reads 66 KiB with the pushdown against 7.5 MiB without it. The most selective ClickBench queries are nevertheless still 1.5-5.5x slower thanParquet. The pushdown was reworked in ref: rework filter pushdown: ActionsDAG converter, temporal types and… #116021 by @m7kss1 (merged into this PR): the filter is translated directly from the query'sActionsDAGinstead of going through aKeyCondition, which addsBool,Date,Date32andDateTime64columns andLIKE/NOT LIKE/startsWithprefix ranges, and reports what reached the scan through theVortexFilterPushdownConjunctsPushed,VortexFilterPushdownConjunctsDropped,VortexScanSplitsandVortexScanEmptySplitsprofile events.The 127 new vendored Rust crates were added in ClickHouse/rust_vendor#74, and ClickHouse/rust_vendor#79 moved them to 0.84.0. Both are merged, so
contrib/rust_vendorpoints atmainrather than at a pull request branch.Workflow [PR]
Sync PR [sync-upstream/pr/112950]
Version info
26.11.1.799-master(included in26.11and later)