Skip to content

Support vector datatype with SqlVector<T> #3443

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

Merged
merged 3 commits into from
Jun 26, 2025

Conversation

apoorvdeshmukh
Copy link
Contributor

Description

This PR adds support for vector datatype with generic SqlType class SqlVector
After considering the feedback from discussion #3382, existing APIs are now supported with revised APIs from SqlVector
This helps in reducing the API surface area for unmanaged types.

Issues

#3317

Testing

Unit Tests for SqlVector
BackWardCompatibility Test suite to ensure support for APIs that worked with varchar(max) for vector datatype.
Tests for native vector datatype.

@Copilot Copilot AI review requested due to automatic review settings June 25, 2025 17:37
@apoorvdeshmukh apoorvdeshmukh requested a review from a team as a code owner June 25, 2025 17:37
Copy link

@Copilot Copilot AI left a 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 replaces the legacy SqlVectorFloat32 type with a new generic SqlVector<T> implementation, updating all client code, tests, and documentation to use the generic API.

  • Introduces SqlVector<T> in place of SqlVectorFloat32, handling only supported unmanaged types
  • Removes SqlVectorFloat32 code, test classes, and related resource entries
  • Updates SQL client surface (SqlDataReader, SqlParameter, SqlBuffer, ISqlVector), tests, and XML docs to reference the generic API

Reviewed Changes

Copilot reviewed 22 out of 23 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlTypes/SqlVector.cs Adds generic SqlVector<T> implementation
src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlTypes/SqlVectorFloat32.cs Deleted obsolete specific vector type
src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlDataReader.cs Replaces GetSqlVectorFloat32 with generic GetSqlVector<T>
src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlParameter.cs Updates vector payload coercion and return to use generic
src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlBuffer.cs Replaces SqlVectorFloat32 uses with generic accessors
src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/ISqlVector.cs Updates interface to match generic API
src/Microsoft.Data.SqlClient/tests/UnitTests/SqlVectorTest.cs Adds unit tests for generic vector behavior
src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/VectorTest/NativeVectorFloat32Tests.cs Updates manual tests to use SqlVector<float>
src/Microsoft.Data.SqlClient/src/Resources/Strings.resx Removes unused vector resource strings
doc/snippets/Microsoft.Data.SqlTypes/SqlVector.xml Adds XML docs for generic SqlVector<T>
src/Microsoft.Data.SqlClient/src/Microsoft/Data/Common/AdapterUtil.cs Removes obsolete vector helpers
Files not reviewed (1)
  • src/Microsoft.Data.SqlClient/src/Resources/Strings.Designer.cs: Language not supported
Comments suppressed due to low confidence (2)

src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/VectorTest/NativeVectorFloat32Tests.cs:100

  • [nitpick] The method name ValidateSqlVectorFloat32Object no longer matches the generic SqlVector<T> type; consider renaming it to something like ValidateSqlVectorObject for clarity.
        private void ValidateSqlVectorFloat32Object(bool isNull, SqlVector<float> sqlVectorFloat32, float[] expectedData, int expectedSize, int expectedLength)

src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/ISqlVector.cs:28

  • [nitpick] Add an XML doc comment for VectorPayload to explain that it returns the raw TDS payload of the vector.
        byte[] VectorPayload { get; }

Copy link
Contributor

@paulmedynski paulmedynski left a comment

Choose a reason for hiding this comment

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

Mostly commentary, and a few minor changes.

paulmedynski
paulmedynski previously approved these changes Jun 25, 2025
cheenamalhotra
cheenamalhotra previously approved these changes Jun 25, 2025
@cheenamalhotra cheenamalhotra added this to the 6.1-preview2 milestone Jun 25, 2025
Copy link
Contributor

@mdaigle mdaigle left a comment

Choose a reason for hiding this comment

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

Looks good. I like the generic API.

mdaigle
mdaigle previously approved these changes Jun 25, 2025
Copy link

codecov bot commented Jun 26, 2025

Codecov Report

Attention: Patch coverage is 79.00000% with 21 lines in your changes missing coverage. Please review.

Project coverage is 58.84%. Comparing base (fc950e8) to head (6095de8).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
...qlClient/src/Microsoft/Data/SqlClient/SqlBuffer.cs 0.00% 10 Missing ⚠️
...ient/src/Microsoft/Data/SqlClient/SqlDataReader.cs 14.28% 6 Missing ⚠️
...lient/src/Microsoft/Data/SqlClient/SqlParameter.cs 25.00% 3 Missing ⚠️
...SqlClient/src/Microsoft/Data/SqlTypes/SqlVector.cs 97.43% 2 Missing ⚠️

❗ There is a different number of reports uploaded between BASE (fc950e8) and HEAD (6095de8). Click for more details.

HEAD has 1 upload less than BASE
Flag BASE (fc950e8) HEAD (6095de8)
addons 1 0
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3443      +/-   ##
==========================================
- Coverage   64.55%   58.84%   -5.71%     
==========================================
  Files         281      275       -6     
  Lines       62519    62220     -299     
==========================================
- Hits        40358    36614    -3744     
- Misses      22161    25606    +3445     
Flag Coverage Δ
addons ?
netcore 61.52% <78.72%> (-5.42%) ⬇️
netfx 62.34% <78.12%> (-5.61%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@cheenamalhotra cheenamalhotra merged commit 27fd1f6 into dotnet:main Jun 26, 2025
233 of 237 checks passed
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.

6 participants