Conversation
westonpace
left a comment
There was a problem hiding this comment.
Marking request changes until we get the extra test case in place. Assuming that test passes I think this can be approved (just request re-review or ping me).
Claude had two other bits of review that seem like nice-to-haves if you want:
rust/lance/src/io/exec/scalar_index.rs:97 — Full-fragment branch duplicates bulk conversion that already exists (CONFIRMED, cleanup)
for id in sequence.iter() { row_ids.insert(id); } should be row_ids |= RowAddrTreeMap::from(sequence.as_ref()) — the same pattern used in retain_fragments a few hundred lines below. The manual loop is a future maintenance hazard if new RowIdSequence segment types are added.
rust/lance/src/io/exec/scalar_index.rs:115 — Two independent async calls per fragment are awaited serially in the Partial branch (CONFIRMED, efficiency)
get_deletion_vector().await? and physical_rows().await? are independent but sequential. futures::try_join! makes them concurrent, halving per-fragment round-trips on object-store-backed datasets.
| translate_addr_set_to_row_ids(dataset, set).await?, | ||
| )), | ||
| NullableRowAddrMask::BlockList(_) => Err(Error::internal( | ||
| "cannot translate a block-list address mask to the row-id domain", |
There was a problem hiding this comment.
Claude seemed to think we could hit this arm in a NOT query but I'm not sure that is the case. If I understand the code correctly we would evaluate the index first, then translate, then apply the NOT. Can you add this test case to verify (main...claude/lance-pr-7565-review-1r8xwx)?
I do think we could still hit this arm if the index search itself returned a block list. However, that isn't the case today so we are ok.
There was a problem hiding this comment.
Thanks, I added the NOT-query regression test from your compare branch:
test_address_domain_index_not_query_with_stable_row_ids- covers both ZONEMAP and BLOOMFILTER
- verifies
x != 42on a stable-row-id dataset matches the non-indexed scan
I also applied the two cleanup suggestions in scalar_index.rs:
- reuse
RowAddrTreeMap::from(sequence.as_ref())in the full-fragment branch - use
futures::try_join!for deletion vector / physical row count in the partial branch
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
…under stable row ids Zone map and bloom filter scalar indices report matches as physical row addresses (fragment_id << 32 | offset). On a dataset that uses stable row ids the address and row-id domains diverge, so the filtered scan resolved these results through the fragment's stable-row-id sequence and silently dropped every match outside fragment 0 (often returning nothing). Mark address-domain indices via a new ScalarIndex::results_are_row_addresses and, in evaluate, translate their results to the row-id domain at the dataset layer (using per-fragment row-id sequences, skipping deleted rows) before they are combined with other results or handed to the scan. Non stable-row-id datasets keep the existing behavior. Closes lance-format#7434
0524116 to
4fe7e69
Compare
Summary
ZONEMAPandBLOOMFILTERscalar indices return silently incomplete results (often empty) for filters on datasets created withenable_stable_row_ids=True. Any value whose matching rows live in fragments other than fragment 0 is partially or completely dropped. The same query is correct with aBTREE/BITMAPindex or withuse_scalar_index=False. This is a correctness bug (false negatives).Fixes #7434.
Root cause
Address-domain indices (zone map, bloom filter) are trained over
_rowaddrand theirsearchreturns physical row addresses (fragment_id << 32 | offset). On a stable-row-id dataset a row's stable id differs from its physical address in every fragment except fragment 0. The filtered-scan path resolves index matches through the fragment's stable-row-id sequence, so an address-domain result fails to intersect and matching rows outside fragment 0 are silently dropped.BTREE/BITMAPare trained with_rowid, so they are unaffected.Fix
Normalize address-domain results to the row-id domain at the dataset/query layer, before they are combined or handed to the scan.
ScalarIndex::results_are_row_addresses()(defaultfalse), overridden totrueforZoneMapIndexandBloomFilterIndex.ScalarIndexLoader::row_addr_result_to_row_ids()(default identity).Datasetimplements it: for stable-row-id datasets it maps each physical address to its stable row id via the per-fragmentRowIdSequence(zipping live physical offsets with the sequence, skipping deleted rows); otherwise it returns the result unchanged.ScalarIndexExpr::evaluate_nullable, translate a leaf's result when the index is address-domain, so all downstreamAND/OR/NOTcombination and scan consumption stay in the row-id domain. This also handles queries that mix address-domain and row-id-domain indices.This keeps zone map / bloom filter acceleration working under stable row ids (no fallback to a full scan) and fixes the same latent bug in the bloom filter index.
Tests
test_address_domain_index_with_stable_row_ids[ZONEMAP|BLOOMFILTER]— reproduces the issue's 5-fragment non-adjacent layout and asserts the index result equals a full scan.test_zonemap_with_stable_row_ids_after_compaction— covers deletions + compaction (physical address != stable id for surviving rows).test_scalar_index.py(155) and the Rust zonemap/bloom unit tests pass;cargo fmt,clippy -D warnings, andruff formatare clean.