Skip to content

fix(blob): reject Blob v2 nested in Map or FixedSizeList at write - #10612

Merged
Xuanwo merged 9 commits into
lance-format:mainfrom
zhangyue19921010:fix/blob-v2-reject-map-fsl-nesting
Nov 9, 2026
Merged

Xuanwo merged 9 commits into
lance-format:mainfrom
zhangyue19921010:fix/blob-v2-reject-map-fsl-nesting

Conversation

@zhangyue19921010

Copy link
Copy Markdown
Collaborator

Blob v2 is supported only under Struct, List and LargeList: the write preprocessor, external URI checks, legacy page normalization, materialization, Managed reference scans and clone walk no other container. Schema promotion still recurses into every child, so since fragment and update writes promote legacy blob input at 2.2+, a legacy blob inside a Map or FixedSizeList became a Blob v2 field whose array the preprocessor passed through untouched, and the writer failed with an opaque FieldTypeMismatch. Native logical Blob v2 input in those containers passed through too and failed in the encoder, which expects the prepared layout; prepared input passed through unchecked.

BlobPreprocessField::new, which every 2.2+ data file writer goes through, now returns NotSupported naming the container field when a Map or FixedSizeList holds a Blob v2 field.

Blob v2 is supported only under Struct, List and LargeList: the write
preprocessor, external URI checks, legacy page normalization,
materialization, Managed reference scans and clone walk no other
container. Schema promotion still recurses into every child, so since
fragment and update writes promote legacy blob input at 2.2+, a legacy
blob inside a Map or FixedSizeList<Struct> became a Blob v2 field whose
array the preprocessor passed through untouched, and the writer failed
with an opaque FieldTypeMismatch. Native logical Blob v2 input in those
containers passed through too and failed in the encoder, which expects
the prepared layout; prepared input passed through unchecked.

BlobPreprocessField::new, which every 2.2+ data file writer goes
through, now returns NotSupported naming the container field when a Map
or FixedSizeList holds a Blob v2 field.

@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 Nov 2, 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 2, 2026
Comment thread rust/lance/src/dataset/blob/write.rs Outdated
// 2.2+ data file writer prepares its input here, so reject the column up front
// rather than let the writer fail on an unprepared array or commit a
// column the rest of the format cannot read.
let container = match field.data_type() {

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.

I tried this with a schema only add, and it looks like we can still add a Map or FixedSizeList with a blob on 2.2+, but can't write to it afterward. Maybe we can enforce this at schema commit side, and we'd still need to allow legacy blobs on 2.1.

WDYT?

#[case::map(true)]
#[case::fixed_size_list(false)]
#[tokio::test]
async fn test_legacy_blob_in_map_or_fixed_size_list_is_rejected_at_v2_2(#[case] map: bool) {

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.

Have you tested the prepared blob v2 logic? Lets add a test for that


/// Blob v2 nests only in Struct and List, so legacy blob input in a Map or
/// FixedSizeList, which 2.2 promotes to Blob v2, is rejected as unsupported
/// instead of failing on the unprepared array.

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: we can make this logic a little more self documenting, and drop this comment

Comment thread rust/lance/src/dataset/blob/write.rs Outdated
}
}

// Blob v2 nests only in Struct and List: the readers, the external URI

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: this comment can be trimmed down maybe to something like:

// Blob v2 readers only support nesting under Struct, List, and LargeList.

Comment thread rust/lance/src/dataset/blob/write.rs Outdated
{
return Err(Error::not_supported(format!(
"Blob v2 fields nested in {container} field '{}' are not supported; Blob v2 can be nested only in Struct, List and LargeList (legacy blob input is stored as Blob v2 from file version 2.2)",
field.name()

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.

Maybe we can cleanup and shorten this error? I don't think we need to explain legacy blob promotion here. Just saying which nesting types are supported should be enough.

The write-time check only runs when a data file is written, so schema
changes that write none, such as add_columns with AllNulls or an empty
Dataset::write, still committed a blob nested in a Map or FixedSizeList
on a 2.2+ table, and every later write to that column failed.

The rule now lives in Schema::check_blob_nesting. The Blob v2 writer
calls it as before, and the manifest build calls it on the final
schema, which covers Overwrite, Merge and Project schemas and the
commit-time promotion of legacy blobs. At commit a blob is rejected if
it is Blob v2 or the table stores 2.2+ files, so legacy blobs in 2.1
tables stay allowed. Fields the parent manifest already rejected under
the same rule are skipped, so a table that already holds one can still
commit and drop it.

The error no longer explains legacy blob promotion, and the fragment
write test gains a prepared descriptor case.
@lance-gatekeeper lance-gatekeeper Bot removed the K-approved Latest Gatekeeper recommendation permits acceptance. label Nov 3, 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 3, 2026
The commit-time exemption looked up the parent field by id and only
asked whether the parent table stored 2.2+ files, which holds for any
field there. A table without non-reusable field ids restarts ids on
Overwrite, so an empty overwrite to a schema with a Blob v2 in a Map
passed whenever the nested blob's id matched any old column, and every
later write to that column failed.

An Overwrite defines a new table, so its schema is now checked in full.
Other operations keep a field only if the parent schema already held it
as a blob nested in a Map or FixedSizeList under the same rule.

The tests collapse into one that covers the writer for legacy and
prepared input, a schema-only add, the empty overwrite, and a legacy
blob that stays allowed in a 2.1 table.
@lance-gatekeeper lance-gatekeeper Bot removed the K-approved Latest Gatekeeper recommendation permits acceptance. label Nov 3, 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 3, 2026
A field metadata update could mark a field nested in a Map as a blob after
the commit-time check had run, publishing a schema no writer accepts. Run
the check on the final schema. Also recognize Map and FixedSizeList by
logical type instead of rebuilding the Arrow type of every subtree.
@lance-gatekeeper lance-gatekeeper Bot removed the K-approved Latest Gatekeeper recommendation permits acceptance. label Nov 3, 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 3, 2026
@zhangyue19921010

Copy link
Copy Markdown
Collaborator Author

Thanks @geruh, all addressed:

  • The nesting rule now lives in Schema::check_blob_nesting and is enforced both when writing data files and at commit. Schema-only adds, empty overwrites and field metadata updates can no longer introduce a Map/FixedSizeList-nested blob on 2.2+, and legacy blobs on 2.1 are still allowed.
  • The tests are consolidated into test_blob_in_map_is_rejected_from_v2_2, which also covers prepared Blob v2 input.
  • The comments and the error message are trimmed to just state the supported nesting types.

@lance-gatekeeper lance-gatekeeper Bot added K-approved Latest Gatekeeper recommendation permits acceptance. and removed K-approved Latest Gatekeeper recommendation permits acceptance. labels Nov 3, 2026
ConcreteFileVersion::V2_2 | ConcreteFileVersion::V2_3
)
};
let already_nested = |field: &lance_core::datatypes::Field| {

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: Is already_nested running check_blob_nesting on the previous schema for each field? Looks like that is validating through the whole schema each time. Could we just collect the fields and compare?

@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, just left one nit fine to ignore!

The commit check walked the parent schema again for every nested blob it
found, through `check_blob_nesting(..).is_err()` used as a predicate.
`Schema::nested_blob_fields` now lists the blobs nested in a Map or
FixedSizeList, and the commit collects the ids the parent schema already
nests this way into a set once, then compares.
@lance-gatekeeper lance-gatekeeper Bot removed the K-approved Latest Gatekeeper recommendation permits acceptance. label Nov 6, 2026
@zhangyue19921010

Copy link
Copy Markdown
Collaborator Author

nit: Is already_nested running check_blob_nesting on the previous schema for each field? Looks like that is validating through the whole schema each time. Could we just collect the fields and compare?

Thanks a lot for all your help! changed.

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

Shared write and commit checks reject unsupported Blob v2 nesting while preserving legacy 2.1 behavior and recovery for existing unsupported schemas. The added regression coverage checks FixedSizeList diagnostics and confirms that rejected metadata updates leave the published dataset unchanged. No blocking findings.

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

Reviewed the integrated head, including the shared writer/commit guard, public API documentation, and Map/FixedSizeList regression coverage. Current-head CI and Gatekeeper are green; no blocking findings.

@Xuanwo
Xuanwo merged commit 65ceba4 into lance-format:main Nov 9, 2026
43 checks passed
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