-
Notifications
You must be signed in to change notification settings - Fork 3.3k
Implement support for SQL Server VECTOR_DISTANCE() #36383
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR implements SQL Server vector search support for Entity Framework Core, adding the ability to work with SQL Server's VECTOR data type and related functions. The implementation provides type mapping, query translation, and validation for vector operations.
Key changes include:
- Added
SqlServerVectorTypeMappingfor SQL Server'sVECTORtype with proper dimensions support - Implemented query translation for vector distance functions and vector properties
- Added model validation to ensure vector properties are properly configured and not used in unsupported scenarios
Reviewed Changes
Copilot reviewed 17 out of 18 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
SqlServerVectorTypeMapping.cs |
New type mapping class for SQL Server vector type with custom comparer and literal generation |
SqlServerVectorTranslator.cs |
Query translator for vector functions (VectorDistance) and vector member access (Length) |
SqlServerTypeMappingSource.cs |
Updated to register vector type mapping and handle SqlVector<float> CLR type |
SqlServerModelValidator.cs |
Added validation for vector properties requiring dimensions and preventing use in JSON |
SqlServerDbFunctionsExtensions.cs |
Added VectorDistance function extension for calculating distances between vectors |
SqlServerDatabaseModelFactory.cs |
Updated scaffolding to properly handle vector columns and dimensions |
| Test files | Comprehensive test coverage for vector functionality, type mapping, and query translation |
Files not reviewed (1)
- src/EFCore.SqlServer/Properties/SqlServerStrings.Designer.cs: Language not supported
Note: this does not include
VECTOR_SEARCH[]translation support (as opposed toVECTOR_DISTANCE()which is included); this is tracked by #36384.Closes #34659