Skip to content

fix(update): keep nested-field index correct when updating a struct column#7412

Merged
jackye1995 merged 1 commit into
lance-format:mainfrom
jackye1995:jack/update-nested-index-coverage
Jun 23, 2026
Merged

fix(update): keep nested-field index correct when updating a struct column#7412
jackye1995 merged 1 commit into
lance-format:mainfrom
jackye1995:jack/update-nested-index-coverage

Conversation

@jackye1995

Copy link
Copy Markdown
Contributor

The update API rejects nested column references (set errors on a . in the column name), so a nested field can only be changed by setting its whole top-level struct column (e.g. SET s = named_struct('x', …)).

commit_impl built fields_for_preserving_frag_bitmap from the struct column's own (parent) field id via field_id(column_name), so an index on a nested child field (a different leaf id) was absent from the set. register_pure_rewrite_rows_update_frags_in_indices then wrongly extended that child-field index over the rewritten fragment, which was therefore treated as indexed and never re-scanned — so the updated rows were silently dropped from queries on the index (false negatives).

The fix collects the full field subtree of each updated column, so a struct-column update marks all descendant field ids as modified. Flat columns are unaffected (no children).

This is the SQL UPDATE counterpart of the merge_insert fix in #7410. Adds a regression test (test_update_struct_column_keeps_nested_index): a BTree index on s.x, an update of the struct column s, and an assertion that the index's effective fragment bitmap is not extended over the rewritten fragment so the updated value is still found.

…olumn

The update API rejects nested column references, so a nested field can only be
changed by setting its whole top-level struct column. commit_impl built
`fields_for_preserving_frag_bitmap` from the struct's own (parent) field id, so
an index on a nested child field was absent from the set. The RewriteRows index
maintenance then wrongly extended that child-field index over the rewritten
fragment, leaving the updated rows unscanned and silently dropped from queries
on the index.

Collect the full field subtree of each updated column so indices on nested
child fields are recognized as modified. Flat columns are unaffected.
@github-actions github-actions Bot added the bug Something isn't working label Jun 23, 2026
@codecov

codecov Bot commented Jun 23, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

dataset: Arc<Dataset>,
update_data: UpdateData,
) -> Result<UpdateResult> {
// Updated columns are top-level (nested references are rejected by `set`), but a

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.

I'm surprised that updated columns have to be top-level? I would think we could do an update on a nested column.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

tracked now in #7420

@jackye1995
jackye1995 merged commit a128e52 into lance-format:main Jun 23, 2026
31 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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants