feat: validate DataFile column_indices at commit time#6414
Merged
westonpace merged 1 commit intoApr 6, 2026
Merged
Conversation
38d4eec to
6f3f6e3
Compare
In Lance file format v2.1+, non-leaf fields (structs, lists) no longer have their own columns — their validity is folded into rep/def levels. Their column_indices entry should be -1. However, users manually constructing DataFile messages could incorrectly assign real column indices, leading to cryptic read-time errors. Add check_column_indices() validation that runs at commit time in both regular and detached commit paths. The validation checks: - fields and column_indices have matching lengths - non-leaf fields have column_index=-1 - leaf/packed-struct/blob fields have a real column index (not -1) Field ids not found in the schema are skipped, since schema evolution operations (cast, drop column) leave old field ids in existing data files. Packed structs and blob fields are exempted from the non-leaf check as they legitimately have column indices even in v2.1+. Closes lance-format#6412 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
6f3f6e3 to
bef97e9
Compare
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
jackye1995
approved these changes
Apr 6, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
check_column_indices()validation inrust/lance/src/io/commit.rsthat rejects non-leaf fields (structs, lists) with real column indices in v2.1+ data files at commit time, preventing cryptic read-time errorscommit_transactionanddo_commit_detached_transactionpathsCloses #6412
Test plan
test_check_column_indices_rejects_struct_with_column— struct with column_index=0 in v2.1 → errortest_check_column_indices_rejects_list_with_column— list with column_index=0 in v2.1 → errortest_check_column_indices_allows_correct_v21— correct indices (non-leaf=-1, leaf>=0) → oktest_check_column_indices_allows_packed_struct— packed struct with real column_index → oktest_check_column_indices_skips_v20— non-leaf with column_index>=0 in v2.0 → ok (no validation)cargo clippy -p lance --tests -- -D warningspassescargo fmt --allclean🤖 Generated with Claude Code