Skip to content

fix(blob): decode legacy blob pages in 2.2 files after promotion - #10454

Merged
Xuanwo merged 2 commits into
lance-format:mainfrom
jackylee-ch:fix/blob-legacy-layout-per-file
Oct 30, 2026
Merged

Xuanwo merged 2 commits into
lance-format:mainfrom
jackylee-ch:fix/blob-legacy-layout-per-file

Conversation

@jackylee-ch

Copy link
Copy Markdown
Contributor

FragmentCreateBuilder::write and write_fragments, behind Python LanceFragment.create and Java Fragment.write(), keep a legacy blob column in the legacy layout when they write a 2.2 file, and 2.2 is their default. Since 13.0.0, the next commit that keeps such a file (append, delete, update, an index or config change, a partial compaction) promotes the column to Blob v2, and reads of the column that reach the file fail:

Value data for Struct("kind": ..., "blob_uri": ...) should contain 5 child data array(s), had 2

v2_adapter picks the legacy descriptor layout by file version alone, so it decodes these pages as v2 descriptors. Tables that the 12.0.0 fragment writer produced this way break on their first commit under 13.0.0 or later.

For 2.2 files the adapter now decides per column: a column whose pages use the blob page layout, which only the legacy encoder writes and which the decoder already dispatches on, is read and normalized as legacy. 2.0 and 2.1 files keep the current rule. Blob projections already open the reader with the full footer; it is now read once before the reader opens, so this adds no I/O.

Testing

test_released_legacy_blob_fragment_reads_after_promotion opens a table written by the 12.0.0 wheel (test_data/v12.0.0/blobs), deletes a row, and checks scans, take_blobs, blob ranges, compaction and the released version. test_read_legacy_and_v2_blob_layouts_from_one_file reads a 2.2 file that holds both layouts. Both fail on main with the error above.

  • cargo test -p lance --release -- blob dataset::fragment legacy, with debug assertions on as in CI
  • cargo fmt --all -- --check, cargo clippy --release --all --tests --benches -- -D warnings

The single-fragment writers keep a legacy blob column in the legacy layout
when they write a 2.2 file. Once a later commit promotes the column to
Blob v2, the dataset adapter decoded those pages as v2 descriptors because
it chose the layout by file version alone, and reads of the column failed.

Decide per column instead: in a 2.2 file, a blob column whose pages use the
blob page layout is read and normalized as legacy. 2.0 and 2.1 files keep
the version rule.

@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 the bug Something isn't working label Oct 29, 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 Oct 29, 2026
@zhangyue19921010 zhangyue19921010 self-assigned this Oct 30, 2026
@lance-gatekeeper lance-gatekeeper Bot removed the K-approved Latest Gatekeeper recommendation permits acceptance. label Oct 30, 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.

The reader-side correction preserves the established blob schema transition without rewriting stored payloads. No merge-blocking issues found.

@lance-gatekeeper lance-gatekeeper Bot added the K-approved Latest Gatekeeper recommendation permits acceptance. label Oct 30, 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.

Approved on the integrated head. The reader decides legacy blob layout per 2.2 file column, and the released 12.0.0 fixture covers promotion, mixed layouts, scans, blob handles and ranges, compaction, and historical reads. Current-head CI and Gatekeeper checks pass.

@Xuanwo
Xuanwo merged commit fb465bb into lance-format:main Oct 30, 2026
41 checks passed
Xuanwo pushed a commit that referenced this pull request Nov 2, 2026
…tes (#10586)

## Problem

Since Lance 13 (#9459), a commit that publishes a 2.2+ data file
referencing a legacy blob column (`lance-encoding:blob` on a binary
field) promotes that column to Blob v2 in the manifest. The dataset
write path already converts legacy input to the Blob v2 layout at 2.2+,
but `FragmentCreateBuilder::write` and `write_fragments` (pylance
`LanceFragment.create`, Java `Fragment.create`), the `Updater` behind
`add_columns`, `merge` and `update_columns`, `write_column_with_version`
and the merge_insert partial path handed their schema to the file writer
untouched. The 2.2 encoder accepts both layouts, so these paths wrote
legacy pages into 2.2 files, which the promotion on commit then
described as v2. Reads failed with `should contain 5 child data
array(s), had 2` until #10454 taught the reader to detect legacy pages
per column; the writers kept producing such files.

## Fix

Every writer path now applies the dataset write policy: when the target
file version is 2.2+, legacy blob fields are promoted with
`promote_legacy_blob_schema` before the writer opens, and `open_writer`
selects the Blob v2 writer whose `BlobPreprocessor` already accepts
binary input. The single-fragment writer opens its writer through
`versions::open_writer` instead of a raw `V2WriterAdapter`,
`open_update_writer` promotes its write schema, and the overlay writer
rejects legacy blob fields at 2.2+ because it writes single columns. The
version rule lives in one exhaustive helper, `versions::writes_blob_v2`,
and the three `WriteParams`-to-`WriterOptions` mappings collapse into
`WriterOptions::from_params`. Data files record only the blob root field
id, so the child ids assigned here need not match the ones the commit
assigns, and files pinned to 2.1 keep the legacy layout as before.

Tests: fragment writes (single and multi file) and `add_columns` at 2.2
assert that the new file's footer stores a Blob v2 descriptor struct.
Xuanwo pushed a commit that referenced this pull request Nov 2, 2026
)

Fix reading legacy blob pages from 2.2 data files after the dataset schema promotes the column to Blob v2. The file adapter now detects the legacy page layout per column, normalizes those descriptors at the dataset boundary, and preserves mixed legacy and Blob v2 layouts in one file.

Add a released 12.0.0 fixture that covers schema promotion, scans, blob handles and ranges, compaction, and historical version reads.

(cherry picked from commit fb465bb)
Xuanwo pushed a commit that referenced this pull request Nov 2, 2026
…tes (#10586)

Since Lance 13 (#9459), a commit that publishes a 2.2+ data file
referencing a legacy blob column (`lance-encoding:blob` on a binary
field) promotes that column to Blob v2 in the manifest. The dataset
write path already converts legacy input to the Blob v2 layout at 2.2+,
but `FragmentCreateBuilder::write` and `write_fragments` (pylance
`LanceFragment.create`, Java `Fragment.create`), the `Updater` behind
`add_columns`, `merge` and `update_columns`, `write_column_with_version`
and the merge_insert partial path handed their schema to the file writer
untouched. The 2.2 encoder accepts both layouts, so these paths wrote
legacy pages into 2.2 files, which the promotion on commit then
described as v2. Reads failed with `should contain 5 child data
array(s), had 2` until #10454 taught the reader to detect legacy pages
per column; the writers kept producing such files.

Every writer path now applies the dataset write policy: when the target
file version is 2.2+, legacy blob fields are promoted with
`promote_legacy_blob_schema` before the writer opens, and `open_writer`
selects the Blob v2 writer whose `BlobPreprocessor` already accepts
binary input. The single-fragment writer opens its writer through
`versions::open_writer` instead of a raw `V2WriterAdapter`,
`open_update_writer` promotes its write schema, and the overlay writer
rejects legacy blob fields at 2.2+ because it writes single columns. The
version rule lives in one exhaustive helper, `versions::writes_blob_v2`,
and the three `WriteParams`-to-`WriterOptions` mappings collapse into
`WriterOptions::from_params`. Data files record only the blob root field
id, so the child ids assigned here need not match the ones the commit
assigns, and files pinned to 2.1 keep the legacy layout as before.

Tests: fragment writes (single and multi file) and `add_columns` at 2.2
assert that the new file's footer stores a Blob v2 descriptor struct.

(cherry picked from commit d2df9e5)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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.

3 participants