Skip to content

fix(file): restore Blob v2 descriptor children in the raw file reader - #10946

Merged
Xuanwo merged 3 commits into
lance-format:mainfrom
ump45nose:fix/10944-blob-v2-raw-reader
Nov 13, 2026
Merged

Xuanwo merged 3 commits into
lance-format:mainfrom
ump45nose:fix/10944-blob-v2-raw-reader

Conversation

@ump45nose

@ump45nose ump45nose commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

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 raw FileReader sees 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 explicit blob projection decodes as Struct([]).

normalize_blob_footer_schema already rebuilt this shape for file concatenation. This moves it from concat.rs into the reader and applies it in FileReader::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 LargeBinary and also satisfy is_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_schema now consumes the schema built by decode_schema instead of cloning it, and DataFilePart::open reuses the already-normalized metadata.file_schema.
  • Adds a checked-in raw v2.2 fixture written by the released Lance 14.0.2 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.py asserts 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_footer opens the historical fixture through the raw FileReader with the default projection and with explicit blob_b / info.payload and id / blob_a projections. 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_children now 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 lint in python/: ruff, pyright, cargo fmt -- --check, and clippy passed.
  • The v14.0.2 fixture was regenerated with 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.

@claude claude Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Claude Code Review

This pull request is from a fork — automated review is disabled. A repository maintainer can comment @claude review to run a one-time review.

@github-actions github-actions Bot added A-encoding Encoding, IO, file reader/writer bug Something isn't working labels Nov 11, 2026
lance-gatekeeper[bot]

This comment was marked as outdated.

@lance-gatekeeper lance-gatekeeper Bot added the K-approved Latest Gatekeeper recommendation permits acceptance. label Nov 11, 2026
@wjones127

Copy link
Copy Markdown
Contributor

@geruh — this fixes the Blob v2 raw file reader with anonymous descriptor children, could you take a look?

@geruh geruh left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: can we add a test with multiple and nested Blob columns? Just want to make sure the child ordering is covered.

Comment thread rust/lance-file/src/concat.rs Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.
@lance-gatekeeper lance-gatekeeper Bot removed the K-approved Latest Gatekeeper recommendation permits acceptance. label Nov 13, 2026

@lance-gatekeeper lance-gatekeeper Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ 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.

@lance-gatekeeper lance-gatekeeper Bot added the K-approved Latest Gatekeeper recommendation permits acceptance. label Nov 13, 2026

@Xuanwo Xuanwo left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@Xuanwo
Xuanwo merged commit b899853 into lance-format:main Nov 13, 2026
44 checks passed
Xuanwo added a commit that referenced this pull request Nov 13, 2026
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]>
Xuanwo pushed a commit that referenced this pull request Nov 30, 2026
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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-encoding Encoding, IO, file reader/writer bug Something isn't working K-approved Latest Gatekeeper recommendation permits acceptance.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants