Repository navigation
Conversation
lanceS3 support for Lance datasetsResolve conflicts for ClickHouse#110548.
There was a problem hiding this comment.
Pull request overview
This PR introduces an initial (read-only) Lance dataset adapter integrated into ClickHouse’s data lake object storage stack, enabling Lance datasets to be queried via new storage engines (LanceLocal/LanceS3) and table functions (lanceLocal/lanceS3) with a custom read pipeline.
Changes:
- Add Lance data lake metadata + custom read pipeline support (via a new optional
readhook returning aPipe). - Add a Rust static library (
_ch_rust_lance) exposing a C FFI (ch_lance.h) used by ClickHouse to open/scan Lance datasets (including an S3 download-to-local-cache MVP). - Register Lance storages/table functions and add stateless + integration tests.
Reviewed changes
Copilot reviewed 34 out of 38 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| utils/list-licenses/list-licenses.sh | Allow a new Rust license expression string used by vendored dependencies. |
| tests/queries/0_stateless/04101_lance_local_readonly_mvp.sql | Adds a stateless regression test for LanceLocal reads. |
| tests/queries/0_stateless/04101_lance_local_readonly_mvp.reference | Expected output for the Lance stateless test. |
| tests/integration/test_s3_table_functions/test.py | Adds MinIO upload helper + integration test for lanceS3. |
| src/TableFunctions/TableFunctionObjectStorage.h | Adds Lance table function aliases when USE_LANCE is enabled. |
| src/TableFunctions/TableFunctionObjectStorage.cpp | Registers lanceS3/lanceLocal in the DataLake table function group. |
| src/Storages/registerStorages.cpp | Registers Lance storage engines when USE_LANCE is enabled. |
| src/Storages/ObjectStorage/StorageObjectStorageSource.cpp | Adds support for configuration-provided custom read Pipe before format-based reading. |
| src/Storages/ObjectStorage/StorageObjectStorageDefinitions.h | Defines LanceLocalDefinition/LanceS3Definition. |
| src/Storages/ObjectStorage/StorageObjectStorageConfiguration.h | Adds a virtual read hook returning std::optional<Pipe>. |
| src/Storages/ObjectStorage/registerStorageObjectStorage.cpp | Registers LanceLocal and LanceS3 engines. |
| src/Storages/ObjectStorage/DataLakes/Lance/tests/gtest_lance_table_state_snapshot.cpp | Adds unit tests for Lance table state snapshot serde and wrapper error behavior. |
| src/Storages/ObjectStorage/DataLakes/Lance/LanceWrapper.h | Declares the C++ wrapper around the Rust FFI (dataset/scan/schema). |
| src/Storages/ObjectStorage/DataLakes/Lance/LanceWrapper.cpp | Implements dataset open/scan/schema export and Arrow record batch import. |
| src/Storages/ObjectStorage/DataLakes/Lance/LanceTableStateSnapshot.h | Defines Lance table state snapshot struct for query pinning/serde. |
| src/Storages/ObjectStorage/DataLakes/Lance/LanceTableStateSnapshot.cpp | Implements Lance snapshot serialization/deserialization. |
| src/Storages/ObjectStorage/DataLakes/Lance/LanceScanDescription.h | Describes scan projection/predicate/count-only options for Lance. |
| src/Storages/ObjectStorage/DataLakes/Lance/LanceReadSource.h | Introduces a pipeline source that emits ClickHouse Chunks from Lance scans. |
| src/Storages/ObjectStorage/DataLakes/Lance/LanceReadSource.cpp | Implements batch iteration and Arrow-to-CH conversion for Lance. |
| src/Storages/ObjectStorage/DataLakes/Lance/LanceMetadata.h | Declares Lance metadata implementation for the DataLake stack. |
| src/Storages/ObjectStorage/DataLakes/Lance/LanceMetadata.cpp | Implements schema discovery, snapshot pinning, iterator, predicate extraction, and custom read Pipe. |
| src/Storages/ObjectStorage/DataLakes/IDataLakeMetadata.h | Adds an optional read hook for dataset-style formats to build pipelines directly. |
| src/Storages/ObjectStorage/DataLakes/DataLakeTableStateSnapshot.h | Extends the variant/type enum to include Lance snapshots. |
| src/Storages/ObjectStorage/DataLakes/DataLakeTableStateSnapshot.cpp | Adds Lance snapshot serialization/deserialization dispatch. |
| src/Storages/ObjectStorage/DataLakes/DataLakeConfiguration.h | Forwards the new read hook to the active metadata implementation; adds Lance configuration typedefs. |
| src/configure_config.cmake | Enables USE_LANCE when the Rust ch_rust::lance target is present. |
| src/Common/config.h.in | Adds USE_LANCE compile-time define. |
| src/CMakeLists.txt | Adds Lance sources to dbms build and links ch_rust::lance into dbms + unit tests when present. |
| rust/workspace/lance/src/lib.rs | Implements the Rust Lance adapter + C FFI, including S3 download-to-tempdir logic and Arrow FFI output. |
| rust/workspace/lance/include/ch_lance.h | C header for the Rust FFI used by ClickHouse. |
| rust/workspace/lance/Cargo.toml | New Rust staticlib crate definition and dependencies. |
| rust/workspace/CMakeLists.txt | Adds ENABLE_LANCE option and exposes ch_rust::lance target when enabled. |
| rust/workspace/Cargo.toml | Adds the lance crate to the Rust workspace members. |
Handle virtual-only `Lance` scans, expand local and S3 coverage, and parameterize `SilkFiberSocketTest` setup for plain and secure sockets.
# Conflicts: # src/Processors/QueryPlan/ReadFromObjectStorageStep.cpp # src/Storages/ObjectStorage/StorageObjectStorageSource.cpp
…the natural end of the scan With several `BatchSource` consumers, one could fail to take the last batch (e.g. while importing it in `Scan::nextBatch`) while another one observed the natural end of the data and set the state to `Ended`. The failing consumer then saw a state other than `Running` and suppressed its exception, so the query succeeded with the batch missing. The coordinator now remembers that the scan ended because the producer finished normally, and a consumer failure after that is still propagated (once). Stops at the limit and cancellations keep suppressing it, because the rows of the lost batch are not needed there. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…enEphemeral` again `static_cast<void>` does not silence the check, which still failed `Build (arm_tidy, 3/4)`. Keep the released pointer and assert that it is the one `Impl` holds. https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=110548&sha=latest&name_0=PR&name_1=Build%20(arm_tidy%2C%203%2F4) PR: ClickHouse#110548 Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
🕵 Merged
All PR-touched translation units compile against the merged |
# Conflicts: # src/Processors/Formats/Impl/ArrowColumnToCHColumn.h
…of a distributed `Lance` worker `ReadFromObjectStorageStep::createIterator` called `StorageObjectStorageSource::ensureDataLakeTableState` unconditionally, so a `lanceS3Cluster` worker pinned its local latest dataset version in the `QuerySession` before requesting a task. If a writer appended a new version between the initiator pinning its snapshot and the worker building its pipeline, the worker then threw `LOGICAL_ERROR` from `QuerySession::getPinned` when reading a task of the initiator's version. The iterator of a distributed read gets the files from the task callback and does not use the table state, and the TopK query condition cache key is not made under distributed processing, so skip the state acquisition for formats whose snapshot arrives in every task object, the same way `StorageObjectStorage::read` does. The `datalake_distributed_worker_latest_snapshot` failpoint now also guards this call, so `test_lance_s3_cluster_worker_does_not_fetch_latest_snapshot` covers it. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…e-and-table-function `master` moved the Rust workspace to `contrib/rust-contrib-workspace` and every crate into its own `contrib/<name>-cmake` directory (`rust/workspace` is gone). Follow that layout for Lance: - `rust/workspace/lance` is now `contrib/lance-cmake`, with the Lance part of the old `rust/workspace/CMakeLists.txt` in `contrib/lance-cmake/CMakeLists.txt`, added from `contrib/CMakeLists.txt`. - The lz4/zstd localization and the symbol stripping use `clickhouse_postprocess_rust_lib`, which `master` introduced for incremental post-processing of Rust libraries. - `contrib/rust-contrib-workspace/Cargo.toml` lists `../lance-cmake` and keeps `panic = "unwind"`. - `contrib/rust-contrib-workspace/Cargo.lock` is `master`'s lockfile with the Lance dependencies added offline (`cargo metadata --offline`); only the wasm-only `wasm-bindgen` family is downgraded by one patch version to match `web-sys` and `wasm-bindgen-futures` in the vendor directory. - `contrib/rust_vendor` points at `ee0f2363`, a merge of the Lance vendor commit `e2c5e2ae` with `master`'s `ed9f05f1` (ClickHouse/rust_vendor#83); the only conflicts were `.cargo-checksum.json` files differing in the `$comment` field, resolved to `master`'s version.
…Utils` header After the merge of `master`, `VirtualColumnUtils.h` no longer includes `FormatSettings.h`, and `filterByPathOrFile` lost its `format_settings` and `file_names` parameters. Call `getFilterByPathAndFileIndexes` with `file_names` directly and filter with `filterSourcesByIndexes`. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…`ArrowColumnToCHColumn` The style check now requires `-WithMemoryTracking` containers in `src/Processors/Formats`: https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=110548&sha=latest&name_0=PR&name_1=Style%20check Co-Authored-By: Claude Opus 5.5 <[email protected]>
…e-and-table-function `master` now links the whole Rust workspace as one static library (`_ch_rust_workspace`, imported once in `contrib/rust-contrib-workspace`), with the members as interface targets (`clickhouse_add_rust_member`). Adapt Lance to it: - `_ch_rust_lance` is a workspace member with the `lance` feature of the root package, re-exported from `src/lib.rs`, and a plain library crate. - `clickhouse_add_rust_member` gets an `ENV` argument, applied to the one cargo run, for the `PROTOC` and `PROTOC_INCLUDE` the Lance build scripts need; `protoc` is a `BUILD_DEPENDS` when it is built natively. - The Lance-specific lz4/zstd localization and the strip step with the list of `ch_lance_*` entry points are dropped: the workspace strip step now localizes the Rust symbols and the bundled C libraries (`zstd-sys` and `lz4-sys` are already in the workspace on `master`) and keeps the C entry points. - `Cargo.lock` is `master`'s lockfile with the Lance packages added offline against the vendor directory; no `master` package changed version. `ReadFromObjectStorageStep::createIterator`: keep `master`'s `if (!iterator_metadata)` (a clone keeps its pinned snapshot) around the distributed-worker snapshot logic of this PR. `StorageObjectStorageSource` takes both `limit_` (this PR) and `shared_create_reader_pool_` (`master`); the new in-order read of `master` passes no limit, as each of its sources is one file of a merge.
|
🕵 Merged |
…e-and-table-function Conflict in `src/TableFunctions/TableFunctionObjectStorage.cpp`: keep both `NOT_IMPLEMENTED` (used by this PR) and `LOGICAL_ERROR` (used by master). Master now rejects the `disk` setting for data lake table functions other than Iceberg and Delta Lake; allow `lance*` functions too, since this PR creates `Lance` configurations over a disk.
…c links resolved `LanceMetadata::getDatasetOptions` checks a local dataset path with `pathStartsWith`, which compares it with symbolic links resolved, so a dataset root that is a symbolic link out of `user_files_path` is already rejected. But it passed the lexical path to the Rust side, which then canonicalized it again, so a root replaced by a symbolic link after the check would be followed. Pass the path with symbolic links resolved, and make `ensure_local_dataset_contained` reject a dataset whose root resolves to a different directory than the one that was checked. Extend `05447_lance_local_symlink_containment` with a dataset root that is a symbolic link out of `user_files_path`. Co-Authored-By: Claude Opus 5.5 <[email protected]>
# Conflicts: # src/Storages/ObjectStorage/IObjectIterator.h # src/Storages/ObjectStorage/StorageObjectStorageConfiguration.h
…e-and-table-function Conflict resolutions: - `contrib/rust_vendor`: merged the Lance vendor commit with master's `chdig v26.11.1` vendor update (new submodule commit 8a53938a). Crates that master pruned but the Lance dependency tree still needs are kept. - `contrib/rust-contrib-workspace/Cargo.lock`: taken from master and re-resolved offline against the merged vendor directory, which only adds the Lance dependencies on top of master's versions. - `StorageObjectStorageStableTaskDistributor.cpp`: taken master's version, which calls `iterator->next` outside the distributor lock (ClickHouse#131-series change "Do not hold the lock of the cluster task distributor while iterating files"). The PR's single critical section is dropped: `LanceDatasetIterator` is internally synchronized, and files queued for a replica that already got an empty task are picked up by the work stealing in `getAnyUnprocessedFile`. Co-Authored-By: Claude Opus 5.5 <[email protected]>
`ScanCoordinator::nextBatch` treated a batch with zero rows like an exhausted row limit: `claimRows(0)` returned zero, so it called `finishAtLimit` and cancelled the whole scan. An empty batch is not the end of the data: the Lance legacy reader applies deletion vectors with `filter_record_batch` and forwards a possibly empty result, so a fragment whose first rows are deleted could yield an empty batch followed by the surviving rows, which were silently lost. Empty batches are now released and skipped; `finishAtLimit` is reached only when the row limit is exhausted. Add a unit test with an empty batch before and after a non-empty one, with and without a row limit. Address review: ClickHouse#110548 (comment) Co-Authored-By: Claude Opus 5.5 <[email protected]>
Mark the accessors and query functions added by this PR with `[[nodiscard]]` (`modernize-use-nodiscard`), and replace the `if constexpr ... else` chain that was split across `#if` blocks in `TableFunctionObjectStorage::parseArgumentsImpl` with independent blocks followed by `if (!configuration)` around the `switch` (`readability-misleading-indentation`). CI report: https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=110548&sha=5b735f9ff8743e649eaa062fd0b5eb7db3c4dfeb&name_0=PR&name_1=Build%20%28arm_tidy%2C%201%2F4%29 PR: ClickHouse#110548 Note: the review link in the previous commit is wrong; the review comment about empty Arrow batches is ClickHouse#110548 (comment) Co-Authored-By: Claude Opus 5.5 <[email protected]>
…gsSecretString` in the `Lance` code The setting is declared as `SecretString` in `S3AuthSettings.cpp`, but `LanceMetadata.cpp` referred to it as `S3AuthSettingsString`, which the style check rejects. https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=110548&sha=4e41fcaea31fc1aa9915342d4bba5393e4b5d620&name_0=PR&name_1=Style%20check ClickHouse#110548 Co-Authored-By: Claude Fable 5.2 <[email protected]>
… host platform `contrib/lance-cmake` pointed `PROTOC` at the `protoc` of the nested native build whenever `USE_MUSL` was set. The nested native build exists only when cross-compiling (see the root `CMakeLists.txt`), and musl is now the default libc of the Linux toolchain files, so in a musl build for the host platform that path does not exist and the build script of `lance-encoding` failed with "Could not find `protoc`". This broke every `arm_tidy` build. Use the same condition as the nested native build, so such builds run the statically linked `protoc` of the main build, the same way `protobuf_generate` does. https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=110548&sha=4e41fcaea31fc1aa9915342d4bba5393e4b5d620&name_0=PR&name_1=Build%20%28arm_tidy%2C%201%2F4%29 ClickHouse#110548 Co-Authored-By: Claude Fable 5.2 <[email protected]>
…e-and-table-function
Conflict resolutions:
- `src/Core/ProtocolDefines.h`, `src/Interpreters/ClusterFunctionReadTask.{h,cpp}`: `master` took
cluster processing protocol version 16 for `DBMS_CLUSTER_PROCESSING_PROTOCOL_VERSION_WITH_DATA_LAKE_FILE_SIZE`,
so the `Lance` versions are now 17 (`..._WITH_LANCE_METADATA`) and 18 (`..._WITH_LANCE_SNAPSHOT_IDENTITY`).
The file size hint is written before the `Lance` trailer, in the order of the versions.
A `Lance` object info takes precedence over `ObjectInfoWithFileSizeHint` in `getObjectInfo`.
- `contrib/corrosion-cmake/CMakeLists.txt`: both sides kept (the `Lance` C flags and
`-fno-sanitize=unsigned-integer-overflow` for UBSan builds).
- `contrib/rust-contrib-workspace/Cargo.toml`: both sides kept (`panic = "unwind"` and the
`[patch.crates-io]` section for the `arrow-rs` and `ipnet` forks). `Cargo.lock` merged cleanly and
`cargo update --workspace` leaves it unchanged.
- `contrib/rust_vendor`: points at `fff8c1fd`, a merge of the `Lance` vendor commit `8a53938a` with
`master`'s `431d6180` (ClickHouse/rust_vendor#87), plus the crates that `master` pruned but the
`Lance` dependency tree still locks (`arrayvec` 0.7.8, `crossbeam-deque` 0.8.8, `libredox` 0.1.25,
`memmap2` 0.9.11, `num_cpus` 1.17.0, `rawpointer` 0.2.1, `toml_edit` 0.25.13, `unicase` 2.10.0),
taken from `cargo vendor --locked`.
Co-Authored-By: Claude Fable 5.2 <[email protected]>
`master` is now 26.12, and the `settings_changes_history` style check requires new settings to be recorded under the current version: https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=110548&sha=d8aa7875e636ccb956af6cb50c3ff3af573705a3&name_0=PR&name_1=Style%20check ClickHouse#110548 Co-Authored-By: Claude Fable 5.2 <[email protected]>
|
🕵 Merged
Verification: the Rust workspace builds with The three open review threads (the |
Resolves #56910
This PR adds experimental read-only support for querying existing Lance
datasets through the ClickHouse data lake object-storage stack.
It introduces:
LanceS3andlanceS3for S3-compatible object storage.LanceLocalandlanceLocalfor locally stored datasets.lanceS3Clusterfor distributed reads across a ClickHouse cluster.ClickHouse filtering,
LIMITpushdown, and count optimizations.Array,Tuple, andMaptypes.observability through
ProfileEvents.The integration is read-only. It does not create Lance datasets, write or
mutate data, build Lance indexes, or provide vector search.
Depends on: ClickHouse/rust_vendor#71
Changelog category (leave one):
Changelog entry:
Add experimental read-only support for querying existing Lance datasets from
local and S3-compatible storage through the
LanceLocalandLanceS3tableengines and the
lanceLocal,lanceS3, andlanceS3Clustertable functions.Example use:
Workflow [PR]
Sync PR [sync-upstream/pr/110548]