Skip to content

fix: align flat fallback NaN distances with Lance - #5293

Merged
yanghua merged 1 commit into
lance-format:mainfrom
ddupg:fix/cosine-zero-norm
Sep 15, 2026
Merged

yanghua merged 1 commit into
lance-format:mainfrom
ddupg:fix/cosine-zero-norm

Conversation

@ddupg

@ddupg ddupg commented Sep 13, 2026

Copy link
Copy Markdown
Contributor

Flat fallback currently assigns cosine distance 1 to zero-norm vectors and can return NaN distances for other metrics, unlike Lance's native search.

Preserve NaN for undefined cosine distances and exclude NaN candidates before local top-k across metrics, while retaining infinite distances. Skip table filtering when there are no NaNs to avoid copying the scanned columns.

Validation: 38 distance-semantics tests passed against PyLance 10.0.0-beta.7, including zero-norm vectors/queries, NaN inputs/queries, and positive/negative infinity preservation. Ruff lint/format, mypy, and diff checks passed.

@github-actions github-actions Bot added the bug Something isn't working label Sep 13, 2026
@ddupg
ddupg marked this pull request as ready for review September 13, 2026 07:43

@yanghua yanghua left a comment

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.

+1

@yanghua
yanghua merged commit a86b052 into lance-format:main Sep 15, 2026
7 of 8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants