Skip to content

Conversation

apoorvdeshmukh
Copy link
Contributor

Description

Adds Vector datatype support for Float32 with Sqltype SqlVectorFloat32

Design Considerations

  • Some inputs have been considered from 📢 Proposal: Introducing SqlType `SqlVectorFloat32` for SQL Server's New VECTOR Data Type #3382
  • Between a generic class definition SqlVector and concrete type SqlVectorFloat32, after comparison it was decided to use concrete types.
  • In future we may consider using SqlVector as base class to isolate common functionality between different Vector types but the public API surface will continue to use concrete definitions so that developers know the exact supported type they are working with.
  • SqlVectorFloat32 will be encouraged as the only way to work with Float32 vector data when using SqlDbType enum value for Vector.
  • Output parameters for reading SqlVectorFloat32 return value will be initialized through SqlVectorFloat32(n) constructor for SqlParameter.Value to allow users to correctly specify the size and type for the vector data they expect to read.

Issues

Closes #3317

Testing

Tests are split into three categories
Unit Tests for SqlVectorFloat32 under SqlVectorFloat32Tests.cs
Backward Compatibility Test Suite to validate behavior when exchanging vector data as varchar(max)
Native Vector Support Test Suite highlighting the supported functionality

This commit adds feature extension for vector datatype support.
Additionally, GenericTDSServer has been enhanced to enable tests
to validate login requests and response for the vector feature extension.
Tests have been added under SqlConnectionBasicTests through
TestConnWithVectorFeatExtVersionNegotiation.
@Copilot Copilot AI review requested due to automatic review settings June 19, 2025 10:06
@apoorvdeshmukh apoorvdeshmukh requested a review from a team as a code owner June 19, 2025 10:06
@apoorvdeshmukh apoorvdeshmukh marked this pull request as draft June 19, 2025 10:06
Copy link
Contributor

@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 introduces support for vector datatypes with a concrete SqlVectorFloat32 class that encapsulates 32‐bit float vector data. Key changes include the addition of the SqlVectorFloat32 type and its handling through TDS feature extensions, updates to resource strings and error messages, and comprehensive tests verifying the new functionality.

Reviewed Changes

Copilot reviewed 36 out of 38 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
src/Microsoft.Data.SqlClient/tests/tools/TDS/TDS/TDSFeatureID.cs Added enum constant VectorSupport for TDS features.
src/Microsoft.Data.SqlClient/tests/tools/TDS/TDS.Servers/* Extended server session and login logic to negotiate and enable vector support.
src/Microsoft.Data.SqlClient/tests/* Added new tests and updated project files for SqlVectorFloat32.
src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlTypes/SqlVectorFloat32.cs Introduced the new type for float vector data with constructors, properties, and serialization to JSON.
Various source files (SqlDbTypeExtensions.cs, TdsEnums.cs, SqlParameter.cs, SqlBuffer.cs, etc.) Updated handling, type mappings, and protocol communication to support vector datatype.
Documentation files Updated XML documentation and resource strings for vector support.
Files not reviewed (1)
  • src/Microsoft.Data.SqlClient/src/Resources/Strings.Designer.cs: Language not supported
Comments suppressed due to low confidence (1)

src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlTypes/SqlVectorFloat32.cs:116

  • [nitpick] Consider ensuring consistent indentation for the NETCORE branch to improve code readability.
        ReadOnlySpan<byte> dataSpan = _rawBytes.AsSpan(8, elementCount * sizeof(float));

@apoorvdeshmukh apoorvdeshmukh added this to the 6.1-preview2 milestone Jun 19, 2025
@apoorvdeshmukh apoorvdeshmukh added P1 Use to label relatively higher severity issues, or issues that impact a large number of customers. Area\Vector Use this for issues that are targeted for the Vector feature in the driver. P2 Use to label moderate priority issue - impacts atleast more than 1 customer. and removed P1 Use to label relatively higher severity issues, or issues that impact a large number of customers. P2 Use to label moderate priority issue - impacts atleast more than 1 customer. labels Jun 19, 2025
@apoorvdeshmukh apoorvdeshmukh marked this pull request as ready for review June 20, 2025 16:16
Copy link

codecov bot commented Jun 20, 2025

Codecov Report

Attention: Patch coverage is 34.00000% with 198 lines in your changes missing coverage. Please review.

Project coverage is 60.17%. Comparing base (27ab95a) to head (897a6f6).
Report is 3 commits behind head on main.

Files with missing lines Patch % Lines
.../netcore/src/Microsoft/Data/SqlClient/TdsParser.cs 15.68% 43 Missing ⚠️
...nt/netfx/src/Microsoft/Data/SqlClient/TdsParser.cs 15.68% 43 Missing ⚠️
...nt/src/Microsoft/Data/SqlTypes/SqlVectorFloat32.cs 56.71% 29 Missing ⚠️
...qlClient/src/Microsoft/Data/SqlClient/SqlBuffer.cs 28.57% 25 Missing ⚠️
...lient/src/Microsoft/Data/SqlClient/SqlParameter.cs 33.33% 18 Missing ⚠️
...ient/src/Microsoft/Data/SqlClient/SqlDataReader.cs 17.64% 14 Missing ⚠️
...SqlClient/src/Microsoft/Data/SqlClient/SqlEnums.cs 33.33% 6 Missing ⚠️
...netcore/src/Microsoft/Data/SqlClient/SqlCommand.cs 20.00% 4 Missing ⚠️
...t/netfx/src/Microsoft/Data/SqlClient/SqlCommand.cs 20.00% 4 Missing ⚠️
...SqlClient/src/Microsoft/Data/Common/AdapterUtil.cs 20.00% 4 Missing ⚠️
... and 4 more

❗ There is a different number of reports uploaded between BASE (27ab95a) and HEAD (897a6f6). Click for more details.

HEAD has 1 upload less than BASE
Flag BASE (27ab95a) HEAD (897a6f6)
addons 1 0
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3433      +/-   ##
==========================================
- Coverage   69.11%   60.17%   -8.95%     
==========================================
  Files         280      275       -5     
  Lines       62128    62209      +81     
==========================================
- Hits        42942    37434    -5508     
- Misses      19186    24775    +5589     
Flag Coverage Δ
addons ?
netcore 63.36% <34.80%> (-9.65%) ⬇️
netfx 62.22% <35.21%> (-6.06%) ⬇️

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.

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.

I have reviewed all of the implementation except SqlVectorFloat32. I'll wait to review that once you make the changes we discussed on Friday.

I will look at the tests after that.

Copy link
Contributor

@edwardneal edwardneal left a comment

Choose a reason for hiding this comment

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

Thanks for opening the earlier discussion. I've added a few comments, but the overall API surface looks good to me.

This was referenced Aug 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area\Vector Use this for issues that are targeted for the Vector feature in the driver. P1 Use to label relatively higher severity issues, or issues that impact a large number of customers.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Native Vector datatype support
5 participants