Skip to content

fix(rule): preserve hidden distance for sort#21

Merged
anoop-narang merged 3 commits intomainfrom
fix/sort-hidden-distance
Apr 8, 2026
Merged

fix(rule): preserve hidden distance for sort#21
anoop-narang merged 3 commits intomainfrom
fix/sort-hidden-distance

Conversation

@anoop-narang
Copy link
Copy Markdown
Collaborator

@anoop-narang anoop-narang commented Apr 8, 2026

Summary

  • preserve _distance through an inner projection when sorting by a vector distance expression that is not selected
  • remap sort expressions to _distance, including alias-wrapped distance expressions
  • add split-provider execution coverage for SELECT id ORDER BY l2_distance(vector, ARRAY[...]) LIMIT k

Testing

  • cargo test -q

Keep _distance in an inner projection when ORDER BY uses a vector\ndistance expression that is not part of the final select list.\n\nThis fixes split-provider execution for queries like SELECT id ORDER\nBY l2_distance(vector, ARRAY[...]) LIMIT k while preserving the final\noutput schema. Add an execution test for the direct ORDER BY shape to\ncover the production case.
Comment thread src/rule.rs
Comment thread src/rule.rs
claude[bot]
claude Bot previously approved these changes Apr 8, 2026
Comment thread tests/execution.rs
@anoop-narang anoop-narang merged commit bfc0d10 into main Apr 8, 2026
5 checks passed
@anoop-narang anoop-narang deleted the fix/sort-hidden-distance branch April 8, 2026 12:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant