Skip to content

feat(fts): support opt-in covering columns for row-level search - #11662

Open
BubbleCal wants to merge 49 commits into
mainfrom
feat/fts-covering-columns
Open

BubbleCal wants to merge 49 commits into
mainfrom
feat/fts-covering-columns

Conversation

@BubbleCal

@BubbleCal BubbleCal commented Nov 30, 2026 •

Copy link
Copy Markdown
Contributor

An FTS search returning ten business IDs can issue several S3 data-file GETs. With create_scalar_index("body", "FTS", covering_columns=["id", "category"]), a partition stores the selected columns in its existing docs.lance. The default writes the ordinary FTS schema. Depends on the format proposal in #11661.

Each winning hit identifies its segment, partition and document ordinal. The scanner projects only the requested carried fields. Dataset field IDs bind the physical columns across renames. Scoring and prewarm project the system columns. A coalesced S3 Range can overlap neighboring stored buffers without filling their cache entries. Partition merge writes each value with its document, and physical remap preserves the values for surviving documents. A missing or invalid binding uses a table Take on the queried dataset version. Residual and indexed hits retain their rank order. A wider projection that includes an uncovered field keeps the normal combined table read.

The writer currently uses raw FullZip for eligible carried fields. On remote storage the reader waits for reuse before filling the encoded column in the session index cache. Each loader reserves space within the session’s fill budget and the DataFusion query pool. A point read checks a winner’s physical extent before decoding. Large remote results whose fields exceed the fill budget can use a grouped table Take. Historical encodings and finite-pool mixed results can also use the ordinary scanner.

Validation

On 826414372, a v4 covering FTS reader intersects the manifest’s claimed coverage with the recorded set of indexed fragments. When stock v15 moves a row by updating an unrelated column, that row is found by the residual scan. The regression checks compare the stable row ID and business ID against a table scan after update, compact, restore and optimize. Both the unrelated-column update and the covered-column update passed. The release compatibility suite passed 484 tests and skipped 15.

On ecd332d9f2, 15 Rust and 23 Python tests passed on managed Linux. Mixed indexed and residual hits returned the correct literal field in both name-collision tests. An unchanged staged input promoted with its table files offline. Two inputs consolidated without retokenization, and a stable-ID deletion triggered a rebuild of the three surviving rows. A 16.0.0b5 writer passed the rename, update, compact and historical-read checks.

With a 32 KiB query pool and 1 MiB object-store blocks, a local projection of a 3-byte ID read 15 bytes from a 132,046-byte document file after scoring metadata was warm. The cold score-only request that populated that metadata read the same file twice in full. These byte counts come from the local ObjectStore trace.

Managed Linux tests at 78bb29c7f9 passed 12 Rust cases, 21 Python cases, five release-compatibility cases and two stock-writer probes. The pressure suite covered 28 routing cases, 12 strict seven-row batch cases, six limited-pool runs and two mixed residual scans. Each of the six pressure runs completed 24 ordinary requests and drained its DataFusion reservation after recovery.

Enabling independent covering declarations sets manifest feature flags. Lance v14.0.3 can read the scoring columns directly but refuses that dataset version, including ordinary scans. v15.0.0 can open the version. After an old writer compacted the table and withdrew coverage, the current reader returned correct updated values, nulls and historical values.

Performance measured at 78bb29c7f9

The 10M measurements below predate these fixes. Performance at the revised head remains unverified. Stock 6ab08ddf7d and reader 78bb29c7f9 queried frozen 10M-row MS MARCO indexes on the same AWS m7i.8xlarge in us-east-1. The covered index was written by 6e89adeafe. Two AB/BA rounds per arm used 32 vCPUs, a 32 GiB cgroup and 8 offered queries/s for BM25 top ten IDs and scores. Warm sessions replayed queries, with explicit prewarm for 64 GiB. SDK defaults were 6 GiB for indexes and 1 GiB for metadata. The separate first-query trial opened a new session and dataset for each query, with 100 fixed query IDs twice per arm at 64 GiB. The tables use nearest-rank percentiles pooled across rounds.

Scenario / metric (lower is better) Stock 6ab08ddf7d Reader 78bb29c7f9 Change
Warm S3, SDK default, p50 40.98 ms 8.94 ms 4.59× faster
Warm S3, SDK default, p99 102.97 ms 29.89 ms 3.44× faster
Warm S3, 64 GiB, p50 41.49 ms 8.73 ms 4.75× faster
Warm S3, 64 GiB, p99 109.69 ms 30.40 ms 3.61× faster
Warm S3, 128 MiB, p50 371.19 ms 532.21 ms 1.43× slower
Warm S3, 128 MiB, p99 706.25 ms 849.28 ms 1.20× slower
Warm gp3, 64 GiB, p50 9.70 ms 8.67 ms 1.12× faster
Warm gp3, 64 GiB, p99 34.06 ms 29.74 ms 1.14× faster
First S3 query, dataset open to EOF, p50 1,376.71 ms 1,450.03 ms 1.05× slower
First S3 query, dataset open to EOF, p99 2,498.44 ms 2,422.94 ms 1.03× faster
Paced 16,384-row stream drain 1.603 s 1.610 s +0.43%
Drain plus six neighboring queries 2.352 s 3.240 s 1.38× slower

Across 12,288 stream queries, the ordered score bits and eligible IDs matched the stock reference every time. 11,593 ordered lists were identical, 544 differed only in tie order and 151 substituted an equally scored hit at the cutoff. All 400 independent first-query observations passed. At SDK defaults the warm arms sustained 8.00 and 8.00 successful queries/s. Peak RSS was 1.67 and 2.18 GiB. Across the four profiles the minimum cgroup headroom was 24.01 GiB. At SDK defaults the fresh-process traffic window, in which requests share a warming session, had p99 1,202.67 versus 1,302.89 ms.

In a 256-query warm S3 replay, data-file GETs fell from 1,416 (5,619,856 B) to 0 (0 B). Five fresh SDK-default sessions recorded 9 column fills totaling 2,259,687,832 stored ID bytes on their second query. Median direct query time on that touch was 44.24 versus 733.07 ms, and on the third touch it was 39.01 versus 6.80 ms. This captures the transfer cost before the column becomes reusable.

At 128 MiB, both paced 16,384-hit streams returned every verified ID and score, cancelled a second reader and completed 24 ordinary requests. The covered arm recorded 16,384 grouped Take rows and zero individual demand rows. A separate replay of actual S3 Range responses counted 760 stock and 761 candidate data-file GETs, carrying 40,976,502 and 40,991,414 B respectively.

On two fresh builds per arm in AB/BA order, the mean build time increased 3.44% (52.95 to 54.78 s). The full index grew 19.59% (2,567,757,861 to 3,070,738,361 B). Both indexes had 7 files. The two document partitions stored 502,512,491 B of ID buffers.

@github-actions github-actions Bot added enhancement New feature or request A-python Python bindings A-index Vector index, linalg, tokenizer A-java Java bindings + JNI A-encoding Encoding, IO, file reader/writer A-docs Documentation and removed enhancement New feature or request labels Nov 30, 2026
@BubbleCal
BubbleCal marked this pull request as ready for review November 30, 2026 21:40

@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 enhancement New feature or request label Nov 30, 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 with a non-blocking risk.

The remaining risk is the performance trade-off at scale: payload files add storage and build work, and entries beyond cache admission still require point reads. The planned 10M-row S3/gp3 comparison remains pending; use ordinary FTS as the baseline when deciding whether to opt in. Keep the storage-contract proposal in #11661 ahead of this implementation in the merge sequence.

Please mark this PR with the breaking-change label: lance_index::scalar::InvertedIndexParams adds a public covering_columns field, so Rust callers using exhaustive struct literals must initialize it.

@lance-gatekeeper lance-gatekeeper Bot added K-approved Latest Gatekeeper recommendation permits acceptance. K-risk Latest Gatekeeper recommendation includes a non-blocking risk. labels Nov 30, 2026
@BubbleCal
BubbleCal marked this pull request as draft December 1, 2026 09:11
@lance-gatekeeper lance-gatekeeper Bot removed K-risk Latest Gatekeeper recommendation includes a non-blocking risk. K-approved Latest Gatekeeper recommendation permits acceptance. labels Dec 1, 2026
@BubbleCal
BubbleCal marked this pull request as ready for review December 1, 2026 15:15
@BubbleCal
BubbleCal marked this pull request as draft December 1, 2026 20:42
@BubbleCal
BubbleCal marked this pull request as ready for review December 1, 2026 21:06
@github-actions github-actions Bot added the A-ci CI / build workflows label Dec 2, 2026
@codecov

codecov Bot commented Dec 2, 2026

Copy link
Copy Markdown

⚠️ JUnit XML file not found

The CLI was unable to find any JUnit XML files to upload.
For more help, visit our troubleshooting guide.

@BubbleCal
BubbleCal marked this pull request as draft December 2, 2026 20:05
@github-actions github-actions Bot added the A-deps Dependency updates label Dec 2, 2026
@BubbleCal
BubbleCal marked this pull request as ready for review December 2, 2026 21:22

@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.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-ci CI / build workflows A-deps Dependency updates A-docs Documentation A-encoding Encoding, IO, file reader/writer A-index Vector index, linalg, tokenizer A-java Java bindings + JNI A-python Python bindings enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants