Skip to content

feat: support taking rows by row ID - #60

Merged
jja725 merged 3 commits into
lance-format:mainfrom
zhangstar333:fix-prefilter-before-nearest
Aug 18, 2026
Merged

feat: support taking rows by row ID#60
jja725 merged 3 commits into
lance-format:mainfrom
zhangstar333:fix-prefilter-before-nearest

Conversation

@zhangstar333

Copy link
Copy Markdown
Contributor

Add lance_dataset_take_rows to read dataset rows using _rowid values.

This is useful for two-phase vector search: first return _rowid and _distance, perform global Top-K, and then fetch the required
columns by row ID.

lance-gatekeeper[bot]

This comment was marked as outdated.

@lance-gatekeeper lance-gatekeeper Bot added the K-changes Latest Gatekeeper recommendation requests changes. label Aug 15, 2026
Comment thread src/dataset.rs Outdated
@lance-gatekeeper lance-gatekeeper Bot removed the K-changes Latest Gatekeeper recommendation requests changes. label Aug 17, 2026

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

Gate recommendation: approve.

The invalid-projection abort is fixed, and both take paths now preserve the FFI error contract through shared fallible projection validation. The direct _rowid lookup remains the right typed, order-preserving mechanism for two-phase retrieval.

@lance-gatekeeper lance-gatekeeper Bot added the K-approved Latest Gatekeeper recommendation permits acceptance. label Aug 17, 2026
@zhangstar333

Copy link
Copy Markdown
Contributor Author

@jja725 PTAL

Comment thread src/dataset.rs
let snap = ds.snapshot();
let projection = projection_from_columns(&snap, col_names.as_deref())?;

let batch = block_on(snap.take_rows(row_id_slice, projection))?;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we guard against missing or invalid row IDs here? Upstream can panic on these inputs, and since this is behind extern "C", that aborts the host process instead of returning an error. A subprocess regression test would help.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for pointing this out @jja725
In the supported call path, the row IDs are produced by _rowid from a scanner created from the same dataset snapshot and are passed unchanged to lance_dataset_take_rows.
This is documented as a same-snapshot precondition and covered by the multi-fragment round-trip tests for both address-style and stable row IDs.

@jja725
jja725 merged commit f1b3670 into lance-format:main Aug 18, 2026
10 checks passed
zhangstar333 added a commit to apache/doris that referenced this pull request Aug 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

K-approved Latest Gatekeeper recommendation permits acceptance.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants