Repository navigation
fix(index): match nested fields by subtree in index maintenance - #10108
Conversation
remap_index's overlay check, prune_overlay_stale_fields_from_indices and the untagged branch of withdraw_in_place_rewrites decided whether an index depends on a field by exact field id. A change reported against a struct then missed an index on one of its children (and the other way around), leaving the index serving stale values. Use field_affects_index on these paths, as fresh_fragments and the overlay staleness checks already do. Closes lance-format#10092.
There was a problem hiding this comment.
✅ Gate recommendation: approve.
Packed-struct writes can report only the parent field ID, so the shared subtree rule addresses a real stale-index failure. The changed paths preserve the existing version gate and keep unrelated fields covered. No blocking issues found.
…lay compaction (#10109) Closes #10091. On a table without stable row ids, a compaction with `defer_index_remap: true` that folds a data overlay on an indexed field left the index covering the compacted rows with their pre-overlay values. `prune_overlay_stale_fields_from_indices` only removed the group's new fragment ids from a stale index's bitmap, but on the deferred path the bitmap still holds the old ids (the fragment reuse index translates them at load time), so nothing was removed and `val = <old value>` kept matching. This removes both the old and the new fragment ids of the group from stale indices, which is the second option the issue gives (per #10090). On the eager path the old ids are already gone, so that path behaves as before. Tagged FRI tables still refuse this compaction, so they aren't affected. Testing: `test_overlay_compaction_reconciles_stale_index` now runs with both eager and deferred remap; the deferred case fails on main (the index still covers the compacted fragment) and passes here. `test_prune_overlay_stale_fields_from_indices` gained a stale index that still covers the old fragment id. `cargo test -p lance-table --lib` passes, as do the `overlay`, `dataset::optimize` and `dataset::index::frag_reuse` tests in `lance`. `cargo fmt --all` is clean and `cargo clippy -p lance -p lance-table --lib --tests -- -D warnings` passes; I didn't run the full-workspace clippy. This touches the same function as #10108 (which changes how stale fields are matched, not which fragment ids are removed), so whichever lands second needs a small rebase. I used an AI coding assistant to help write this change and the tests; I reviewed the diff and ran the checks above. Co-authored-by: ump45nose <[email protected]>
b9a2e48 to
1fdc8f4
Compare
The overlay in this case records geometry's nested field ids, while the committed RTree index records geometry itself. With subtree matching, folding the overlay now drops the first compaction's output from the committed index, and compaction does not mix indexed and unindexed fragments, so the second compaction left two fragments. Overlay a source of each first-round group so both outputs leave the index and the second compaction still merges them.
|
After the rebase, |
Closes #10092.
Three index maintenance paths decided whether an index depends on a field by exact field id: the overlay check in
remap_index/remap_index_tagged,prune_overlay_stale_fields_from_indices, and the untagged branch ofwithdraw_in_place_rewrites. A change reported against a structsthen left coverage on an index overs.x(and a change tos.yleft an index oversalone), so the index could keep serving the old values.These paths now use
field_affects_index, the same subtree rulefresh_fragmentsand the overlay staleness checks already use:overlay_affects_index;prune_overlay_stale_fields_from_indicestakes the schema and matches overlaid fields by subtree;withdraw_in_place_rewritesdrops the rewritten fragment from every index that depends on a rewritten field. The tagged branch is unchanged.IndexMetadata.fieldsalready holds the covering fields, so this matches thefields ∪ covering_fieldssubtree rule from #10090. Like the issue says, I haven't confirmed that a current writer reports only the parent id; this just makes the three paths agree with the rest.Testing: added
test_prune_overlay_stale_fields_matches_nested_fieldsandtest_untagged_in_place_rewrite_withdraws_nested_fields(parent change vs. child index, child change vs. parent index, unrelated field).cargo test -p lance-table --libpasses, as do thedataset::optimize::remapping(49) andoverlay(206) tests inlance.cargo fmt --allis clean,cargo clippy -p lance --lib -- -D warningsis clean, andcargo clippy -p lance-table --testsshows nothing in the touched code (with-D warningsit stops on existing dead-code warnings inlance-io's throttle module). I didn't run the full-workspace clippy.I used an AI coding assistant to help write this change and the tests; I reviewed the diff and ran the checks above.