Skip to content

feat(blob): support mixed v1 and v2 files - #9459

Merged
Xuanwo merged 1 commit into
mainfrom
xuanwo/mixed-blob-versions
Sep 22, 2026
Merged

Xuanwo merged 1 commit into
mainfrom
xuanwo/mixed-blob-versions

Conversation

@Xuanwo

@Xuanwo Xuanwo commented Sep 22, 2026

Copy link
Copy Markdown
Member

Allow an existing 2.0/2.1 Blob column to accept 2.2+ files without rewriting its historical payloads. The target file version selects the encoding, using the existing mixed-data-file capability.

The first v2 file commit promotes the column's snapshot schema. Scans normalize older descriptors to v2 Inline descriptors, including scans restricted to old fragments; historical snapshots retain their original schema. The table's default file version remains unchanged, so v2 struct writes and v2 compaction require an explicit 2.2+ target.

Compatibility coverage uses legacy files generated by released Lance 8.0.0 and checks payloads, null/empty values, BlobFile and range reads, fragment selection, historical snapshots, and compaction while asserting that the original data files are unchanged.

Related to #9458, which tracks the user-visible descriptor schema transition.

@github-actions github-actions Bot added A-docs Documentation enhancement New feature or request labels Sep 22, 2026
@Xuanwo
Xuanwo marked this pull request as ready for review September 22, 2026 06:46

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

Promoting the current snapshot on its first 2.2+ Blob file and normalizing legacy descriptors at the dataset boundary satisfies the mixed-version contract without rewriting historical payloads. Root field identity, historical snapshots, the dataset default file version, and original data files remain stable; the paired mixed-version feature flag fences incompatible readers and writers.

@lance-gatekeeper lance-gatekeeper Bot added the K-approved Latest Gatekeeper recommendation permits acceptance. label Sep 22, 2026
@Xuanwo
Xuanwo merged commit f3dc936 into main Sep 22, 2026
38 of 39 checks passed
@Xuanwo
Xuanwo deleted the xuanwo/mixed-blob-versions branch September 22, 2026 14:16
wjones127 pushed a commit that referenced this pull request Oct 6, 2026
Since #9459, create and append on file format 2.2+ accept legacy
blob-marked binary input and convert it to Blob v2. Merge insert still
compared the source schema strictly, so the input that created a table
failed to upsert into it: "`blob` should have type struct but type was
large_binary". With 2.2 now the default, this hits any table written
from legacy blob input.

The merge source checks now match legacy blob input to Blob v2 as append
does, and the pre-write blob rewrite passes byte input through to the
writer, which already converts it.
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
…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)
Xuanwo added a commit that referenced this pull request Nov 12, 2026
Complete the descriptor-transition contract from #9458 and #9459 with
regression assertions for exact historical descriptors, an unchanged
default storage version, and implicit-version compaction failing without
committing a new snapshot. Remove the obsolete schema-transition
discussion link while retaining the requirement to explicitly select
`data_storage_version >= 2.2` for mixed-column Blob v2 compaction.

Validation evidence for this unchanged patch contains five passing Rust
behavior cases: all four mixed-version cases and the released
legacy-fragment regression. Formatting and diff checks pass. Workspace
Clippy and the targeted lance Clippy run are blocked by the existing
`clippy::undocumented_unsafe_blocks` error at
`rust/lance-encoding/src/data.rs:1200`; the separate fix is tracked in
#10980 and is not duplicated here. Full workspace tests and Python
bindings were not run.

Closes #9458.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-docs Documentation enhancement New feature or request K-approved Latest Gatekeeper recommendation permits acceptance.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants