Skip to content

fix(scan): preserve candidates from inexact scalar index results - #9789

Merged
wjones127 merged 1 commit into
mainfrom
gatekeeper/fix-9787-1
Oct 9, 2026
Merged

wjones127 merged 1 commit into
mainfrom
gatekeeper/fix-9787-1

Conversation

@lance-gatefixer

Copy link
Copy Markdown
Contributor

Fixes #9787

Combining a negated exact scalar predicate with a zone map predicate can produce an AtLeast result: some rows are guaranteed matches, while others still need a filter recheck. The reader incorrectly used only the guaranteed rows for its fallback scan, dropping candidate matches when no limit applied or the guaranteed rows could not satisfy the limit.

Preserve the full candidate range for fallback scans and retain the guaranteed ranges for successful limit pushdown. Add small multi-fragment regressions covering the reported filters, NULL values, stable row IDs, and limit/offset fallback.

Validation:

  • Confirmed all six compound-filter regression cases fail before the fix; plain NOT passes.
  • cargo test -p lance --profile ci test_not_or_zone_map: 8 passed.
  • cargo test -p lance --profile ci io::exec::filtered_read::tests: 94 passed.
  • cargo fmt --all.
  • cargo clippy --all --tests --benches -- -D warnings.

@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 repository is configured for manual code reviews. Comment @claude review for a one-time review, or @claude review always to subscribe this PR to a review on every future push.

Tip: disable this comment in your organization's Code Review settings.

@github-actions github-actions Bot added the bug Something isn't working label Oct 8, 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.

Preserving the full fallback range fixes the silent row loss in #9787 while retaining guaranteed-match limit pushdown. The scanner regressions and all 94 filtered-reader tests pass locally (reader suite run serially).

@lance-gatekeeper lance-gatekeeper Bot added the K-approved Latest Gatekeeper recommendation permits acceptance. label Oct 8, 2026
@wjones127
wjones127 merged commit 0b2472b into main Oct 9, 2026
@wjones127
wjones127 deleted the gatekeeper/fix-9787-1 branch October 9, 2026 18:26
@wjones127 wjones127 added the critical-fix Bugs that cause crashes, security vulnerabilities, or incorrect data. label Oct 9, 2026
ruslan-shaydullin added a commit to ruslan-shaydullin/lance that referenced this pull request Oct 12, 2026
Merge upstream main after the external indexed input for hybrid
queries (lance-format#9847) and the scalar index candidate fix (lance-format#9789). Only the
fts.rs test import list conflicted; it now carries both sides, and the
restricted Match patch itself is unchanged.

Signed-off-by: Ruslan Shaydullin <[email protected]>
wjones127 pushed a commit that referenced this pull request Oct 19, 2026
The planner correction for #9772 has landed on `main` through #9789:
lower-bound index results retain candidates that still need predicate
evaluation. This PR adds regression coverage for NGram needles whose
trigrams are all removed by tokenization.

Compare indexed and unindexed results for punctuation, Unicode, empty
strings, and nulls across three fragments and both row-ID modes. Extend
the lower-bound scan test with empty guaranteed sets and partial
limit/offset results.

The merged base includes #9850, which corrects the compatibility
environment's namespace dependency for `pylance>=14.0.0b10`.

Validation:

- Six punctuation cases failed on the original implementation and pass
with the planner correction.
- `cargo test -p lance --profile ci test_ngram --lib`: 20 passed.
- `cargo test -p lance --profile ci test_not_or_zone_map --lib`: 8
passed.
- `cargo test -p lance --profile ci io::exec::filtered_read::tests --lib
-- --test-threads=1`: 141 passed.
- `cargo fmt --all`: passed.
- `cargo clippy --all --tests --benches -- -D warnings`: passed.
- `uv run pytest --run-compat python/tests/compat/test_venv_manager.py`:
14 passed.
- `uv run make lint`: passed (Ruff, type checking, Rust formatting, and
binding Clippy).
- `make build` from `python/`: passed.
- Beta dependency dry-run: `pylance==14.0.0b10` resolves with
`lance-namespace>=0.13.0,<0.14`.

The filtered-read suite runs serially to avoid interference between
shared tracing counters.

Fixes #9772

<!-- lance-gatekeeper-fix:v1 agent=9fb12c67db5d937ba8c02cbd14ef1f66
generation=1 -->

Co-authored-by: Gatefixer <312823363+lance-gatefixer[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working critical-fix Bugs that cause crashes, security vulnerabilities, or incorrect data. K-approved Latest Gatekeeper recommendation permits acceptance.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: NOT x OR <range> drops rows when a zone map answers the range

1 participant