Repository navigation
Conversation
Signed-off-by: Ruslan Shaydullin <[email protected]>
|
Thanks @wjones127 for enabling the previous CI run. It exposed outdated expected plans in Could you approve the five code workflows on this updated head? They currently report |
|
Hi @sbrunk, would you be able to check the two single-column The updated head has passed Rust, Python and Java CI. This remains a partial fix: |
|
@ruslan-shaydullin I couldn't find the orignal repro code anymore but based on the repro example in the ticket I checked againt and it looks good! |
Merge current main while preserving restricted Match corpus scoring. Adapt the candidate-prefilter constructor and assert exact residual fragment coverage introduced by upstream scalar-index pruning. Signed-off-by: Ruslan Shaydullin <[email protected]>
|
Synced with main after #9444 and #9640; only the import lists conflicted, the patch itself is unchanged. The plan, #9058, FTS executor, BM25F and scalar-pruning test groups, fmt and clippy all pass locally on the new head. @wjones127 could you approve the workflow runs again when you get a chance? |
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]>
There was a problem hiding this comment.
The sync and new multi-segment regression preserve the correction for exact, row-level single-column Match on append-only data: prefilters and fragment selection do not alter corpus statistics. Broader scoring cases remain tracked by #9058.
Selective prefilters or fragment selections still read and tokenize the full unindexed text tail, so latency and peak memory scale with that tail. Keeping the FTS index current mitigates the cost.
…11139) Related to #9058. Follow-up to #9243. ## Problem #9243 added a plan (`MatchCorpus`) that scores an exact `Match` or row-level `Phrase` query against one set of corpus statistics: the committed index statistics plus every unindexed row. Both the indexed arm and the unindexed arm use it, so scores no longer depend on the query filter or on how much of the table is indexed. That plan was limited to append-only tables. The planner skipped it as soon as any fragment in the dataset had a deletion file. One deleted or updated row anywhere in the table sent every such query back to the older plan and the behaviour described in #9058. Deletion files stay until compaction rewrites the fragment, so a table that receives updates rarely qualified. ## Change Remove that one condition from `plan_corpus_query`. A deletion file no longer decides which plan runs. Every other eligibility rule is unchanged (primary FTS, exact single-column `Match` or row-level `Phrase`, default `wand_factor`, no `fast_search`, no data overlay, V2/V3 postings). No execution code changes. The two arms already handle deletions: | | Statistics it contributes | Rows it can return | | --- | --- | --- | | Indexed segments | Values stored at index time. Rows deleted after indexing are still counted. | Deleted rows are masked out. | | Unindexed fragments | Counted while scanning. The scan skips deleted rows, so only live rows are counted. | Live rows only. | ## Scoring on a table with deletions Example: 1000 rows are indexed, 100 of them are later deleted, and 50 rows are appended without indexing. The shared scorer uses a document count of 1050 (1000 from the index, 50 from the scan); the exact live count is 950. Document frequency and average length are built the same way. This is the approximation the indexed arm of the older plan already uses, so no score gets less accurate with this PR. What changes is that both arms now use the same numbers on these tables too. An update counts twice until the index is rebuilt: the old version in the index statistics and the new version in the scan. Making the indexed statistics exclude deleted rows needs a pass over the posting list of every query term. That stays with #9058. ## Tests In `rust/lance/src/dataset/tests/dataset_index.rs`, next to the existing #9058 cases and reusing their helpers: - `test_fts_9058_deletions_corpus_scores`: one row is deleted in an indexed fragment and one in an unindexed fragment. The plan contains `MatchCorpus`, the deleted rows are not returned, and rows and scores match the raw-text BM25 oracle computed over "indexed rows as of index time plus live unindexed rows". Cases: no filter, prefilter, filter; with and without stable row ids; with and without a limit. Checked before and after an append-mode `optimize_indices`: the existing segments keep their statistics and the new segment is built from live rows, so the expected scores are the same at both stages. - `test_fts_9058_phrase_deletions_corpus_scores`: the same check for a row-level `Phrase` query. One indexed and one unindexed row that match the phrase are deleted; the plan contains `MatchCorpus` and `PhraseQuery`, neither deleted row is returned, and scores match the raw-text phrase oracle over the same corpus definition. Cases: no filter, prefilter, a filter that selects only unindexed rows, an explicit fragment selection; with and without stable row ids; before and after an append-mode `optimize_indices`. - `test_fts_9058_fully_deleted_fragment`: a fully deleted indexed fragment and a fully deleted unindexed fragment return no rows and do not fail, before and after index optimization. - `test_fts_9058_deleted_candidates_stay_excluded`: existing test, assertions unchanged, comment updated. All of the above run in CI. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude <[email protected]>
Related to #9058.
For the two reported single-column
Matchcases, index optimization changes the winner fromalphatobetaafter incorporating already appended rows, although the searchable data and query are unchanged.This partial fix scores eligible restricted matches against committed posting statistics plus the complete unindexed corpus. Flat candidate filtering runs after corpus collection; indexed masks still constrain indexed top-k. A private owner gives each execution a fresh shared scorer. The restricted path handles an effective top-k limit of zero without constructing a zero-sized sort.
The correction covers exact, row-level scalar-string
Matchqueries with a prefilter or explicit fragment selection on the supported append-only corpus. Indexed scoring uses V2/V3 postings. Deletion/stale-text-overlay scoring, legacy postings, fuzzy/phrase/Boolean queries, BM25F/combined_fields, and the unfiltered Hybrid approximation remain outside this correction. #9058 remains open for the broader scoring work.Integration
Head
17cbb29a786a606cc1c66dd57fedc898edf617eecontains merge commit3bb7aecd99f71df569e64fd4829c2b05a6adfa6c, which integrates upstreammainatc85ad6414715792dfc7797a791a3560a68c3fa44. The resolution preserves #9872's per-segment allowed-row filtering for stable row IDs and #10251'slance-datafusion-execdependency boundary, while retaining the restricted Match planner and emission-time candidate filtering.Regression commit
17cbb29a786a606cc1c66dd57fedc898edf617eeadds one focused case with two committed FTS segments, a residual unindexed tail, and a restricted exact root Match under stable row IDs. It compares both returned rows and exact scores with the independent raw-text BM25 oracle.Validation
Local validation covered the new multi-segment and residual-tail exact-score regression, the full 9058 suite, Legacy/Stable plan variants, the stable-row-id segmented-index paths, and workspace formatting and clippy. GitHub Actions on the current head are the authoritative CI record; results from older heads are not inferred as current.
The global corpus requires reading and tokenizing all unindexed text, including rows outside the candidate set. Corpus construction reuses committed posting statistics without retokenizing indexed text. A scalar prefilter with an overlay-stale index can still contain a consumable
OneShotExec; fresh scorer state does not make that existing input replayable. Sequential and concurrent reuse are verified on the append-only fixtures. No performance claim is made.Thanks to @sbrunk and the automated reviewer for the report and reproductions during #7905; its emission-filter/shared-scorer work informed this follow-up.