Repository navigation
fix(file): restore Blob v2 descriptor children in the raw file reader - #10946
Conversation
|
@geruh — this fixes the Blob v2 raw file reader with anonymous descriptor children, could you take a look? |
geruh
left a comment
There was a problem hiding this comment.
LGTM thanks for raising @ump45nose! I left 2 non blocking nits here.
| #[case::with_ordinary_column(false, true)] | ||
| #[case::with_legacy_blob(true, false)] | ||
| #[tokio::test] | ||
| async fn test_raw_reader_reads_blob_v2_descriptor_children( |
There was a problem hiding this comment.
nit: can we add a test with multiple and nested Blob columns? Just want to make sure the child ordering is covered.
There was a problem hiding this comment.
Since read_all_metadata already normalizes the schema, can we just reuse metadata.file_schema here and keep the helper private?
Add a Lance 14.0.2 raw file fixture with multiple top-level Blob v2 columns and a nested Blob, regenerate it with version-asserting datagen, and verify full and projected raw reads. Normalize the footer schema in place and let concatenation reuse the normalized file schema.
There was a problem hiding this comment.
✅ Gate recommendation: approve.
Normalizing the footer before projection repairs existing Blob v2 files without changing their stored format. Local regression checks cover the released 14.0.2 fixture, multiple and nested Blob columns, legacy Blob controls, and whole-schema and explicit projections.
Xuanwo
left a comment
There was a problem hiding this comment.
Final acceptance for beta inclusion, authorized by the delivery owner.
Scope verified against immutable Git objects: head tree 81c17b781269926034f7e4f06503e46cf9ce50cb, sole parent 041861c, 6 files +778/-76. Merging onto current main 67c0f32 yields candidate tree 0c52f52402b8bc1159c99f0fa63e195cd62595cb whose patch is byte-identical to the reviewed patch (199b90332ed77531a6c292a729b451d32d7fb8161502149f4106671300f37172); main's #10966 change is preserved untouched and conflicts with nothing here.
Checks on this head: 43 total, 39 success, 4 skipped by their own path/label conditions (Arrow ordering compatibility, aws-integtest, pylance crate Rust tests, Python Linux 3.14 ARM), none pending or failing. The two inline nits are non-blocking and already covered on this head.
Bulk reads from already opened `BlobFile` handles can now reuse the bounded Blob read planner without taking descriptors again. Rust exposes `lance::blob::read_blob_files` and `read_blob_file_ranges`; Python exposes the same APIs at the `lance` module level. This addresses the handle-input portion of #6178. Requests retain their input identity, including NULL and empty values, with ordered results by default. Defaults come from the first non-null handle's own store and can be overridden. Empty and all-NULL inputs perform no I/O. Handles keep their source and ranges across dataset commits while their backing files remain available; External objects retain their provider's consistency semantics. Public Rust and Python docs state that handles already closed when the read stream is created are rejected; closing a handle afterwards does not cancel reads already planned. Payload grouping distinguishes ObjectStore Arc instances and object paths, so stores with matching prefixes cannot share credentials, cache state, or payloads accidentally. Execution schedulers are shared across paths within the same store instance; cached schedulers retain that Arc, preventing address reuse while the execution is alive. Handle and row-selector reads use the same bounded executor, with no placeholder row addresses in the internal execution path. The branch is merged with current `main` (`4344ec32`), preserving the incoming Blob raw-reader schema normalization from #10946 and the session/version stub additions; the original two contributor commits remain in history. Validation on the integrated tree: 373 targeted Rust Blob tests passed (233 `dataset::blob`, 140 `dataset::tests::dataset_blob`), including all 11 new handle cases; 146 `lance` doctests passed, including both new public examples; full-workspace `ci` Clippy and formatting passed. Python: 292 `test_blob.py` cases passed, including all 17 new handle cases; `uv run make lint` passed. The docs site builds; external integration docs were absent and stayed on their placeholders. Live S3/MinIO credential isolation and latency benchmarks have not been run; request-count tests do not establish a latency claim. Formal approval is still pending. --------- Co-authored-by: Claude Opus 5.5 <[email protected]> Co-authored-by: Xuanwo <[email protected]>
A raw Blob v2 file read selecting `blob.kind` and `blob.size` can silently return the file offset as the size. On 16.0.0b5, blobs containing one byte and six bytes returned sizes of 0 and 64. Selecting only `size` can instead fail while decoding a UInt8 buffer as UInt64. Decode the packed descriptor with the complete child layout from the file footer, then project the decoded batch by name. The file's physical column indices identify the source descriptor, including for nested and reordered projections. This works for both streaming and blocking reads and does not require rewriting existing files. It builds on the raw footer reconstruction in #10946. Regression coverage exercises non-contiguous children, a single child, and reversed children on a nested Blob across batch boundaries. It checks payload lengths, field order, NULL versus empty, and the neighboring scalar column. Validation: `cargo test --profile ci -p lance-file --lib` passed all 675 tests. All six new regression cases failed on the unpatched base. Formatting and workspace Clippy (`cargo clippy --all --tests --benches -- -D warnings`) also passed. Co-authored-by: everySympathy <[email protected]>
Refs #10944.
The structural writer stores a Blob v2 column as its descriptor struct, and the descriptor children (
kind,position,size,blob_id,blob_uri) go into the footer with field id and parent id-1.Schema::try_from(&Fields)then treats each of them as a root, so the rawFileReadersees the Blob field with no children followed by five orphan top-level fields. Whole-schema reads fail with "the projection specified the column index 5 but there are only 1 columns", and an explicitblobprojection decodes asStruct([]).normalize_blob_footer_schemaalready rebuilt this shape for file concatenation. This moves it fromconcat.rsinto the reader and applies it inFileReader::decode_schema, so every raw read of a footer schema (and concatenation, which goes through the same path) sees the Blob field with its descriptor children again. It only reinterprets the existing footer, so files that are already written read correctly without a rewrite; the file format and writer are unchanged. It's a no-op when the schema has no childless Blob descriptors.While moving it I tightened which fields get children back: only a childless Blob field with the descriptor's struct type. Legacy Blob v1 columns are stored as plain
LargeBinaryand also satisfyis_blob(), so with the old check a v1 column placed before a v2 column would have taken the v2 column's descriptor children. Concat rejects Blob v1, so this didn't matter there, but the raw reader can see mixed files.Follow-up on this branch:
normalize_blob_footer_schemanow consumes the schema built bydecode_schemainstead of cloning it, andDataFilePart::openreuses the already-normalizedmetadata.file_schema.LanceFileWriter. It has two top-level Blob v2 columns and one nested Blob v2 column, with known inline payloads, a null, and an empty value.test_data/v14.0.2/datagen.pyasserts the Lance version, regenerates the file, and asserts the released 14.0.2 reader still rejects its footer.test_raw_reader_reads_released_blob_v2_footeropens the historical fixture through the rawFileReaderwith the default projection and with explicitblob_b/info.payloadandid/blob_aprojections. It checks parent field ids, nullability, metadata, descriptor child order, exact size/position/kind/blob_id values, and that each descriptor group belongs to its own Blob parent.test_raw_reader_reads_blob_v2_descriptor_childrennow covers two top-level Blob columns and a nested Blob, plus the ordinary-column and legacy Blob v1 controls.Testing:
cargo test --profile ci -p lance-file --lib: 392 passed.cargo test --profile ci -p lance --lib dataset::tests::dataset_blob::: 135 passed.cargo test --profile ci -p lance --lib dataset::tests::data_file_part::: 27 passed.cargo fmt --all -- --check: passed.cargo clippy --profile ci --all --tests --benches -- -D warnings: passed.uv run make lintinpython/: ruff, pyright,cargo fmt -- --check, and clippy passed.uv run --no-project --with pylance==14.0.2 --with pyarrow==26.0.1 datagen.py; the released reader rejected the generated footer as expected.The C writer/reader combinations from the issue live in lance-c, so they aren't covered here. This does not claim that raw Rust file tests replace the downstream C matrix.
The original diagnosis and fix are from @ump45nose. I used an AI coding assistant to help write this change and the tests; I reviewed the diff and ran the checks above.