Skip to content

Backport 6.1 | API enhancements for vector datatype #3472

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 1 commit into from
Jul 12, 2025

Conversation

apoorvdeshmukh
Copy link
Contributor

This is a direct port of #3468 from main to release/6.1

@Copilot Copilot AI review requested due to automatic review settings July 11, 2025 12:50
@apoorvdeshmukh apoorvdeshmukh requested a review from a team as a code owner July 11, 2025 12:50
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 ports issue #3468 from the main branch to the 6.1 release, introducing a CreateNull factory for SqlVector<T>, changing vector handling to a readonly struct, and updating related components and tests.

  • Added SqlVector<T>.CreateNull(int length) and replaced constructor calls for null vectors.
  • Refactored SqlVector<T> from a sealed class to a readonly struct, moved Size to a private field, and updated interface implementations.
  • Updated unit and manual tests, SqlParameter/SqlBuffer handling, SqlDataReader logic, reference assemblies, and documentation to support the new vector API.

Reviewed Changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated no comments.

Show a summary per file
File Description
src/Microsoft.Data.SqlClient/tests/UnitTests/SqlVectorTest.cs Switched from constructor to CreateNull in null-vector tests and realigned Size assertions.
src/Microsoft.Data.SqlClient/tests/ManualTests/.../NativeVectorFloat32Tests.cs Updated test data to use vector length only, removed old size parameters, and adjusted parameter size logic.
src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlTypes/SqlVector.cs Converted SqlVector<T> to a readonly struct, added CreateNull, and replaced public Size property with an internal field.
src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlParameter.cs Ignored Size for vector parameters in setter and Prepare, and updated vector return creation to use CreateNull.
src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlDataReader.cs Simplified vector-to-string logic in GetFieldValueFromSqlBufferInternal.
src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlBuffer.cs Adjusted GetSqlVector<T> to use CreateNull for null vectors.
src/Microsoft.Data.SqlClient/netfx/ref/Microsoft.Data.SqlClient.cs Updated reference API for SqlVector<T> to readonly struct and added CreateNull.
src/Microsoft.Data.SqlClient/netcore/ref/Microsoft.Data.SqlClient.cs Updated reference API for SqlVector<T> to readonly struct and added CreateNull.
doc/snippets/Microsoft.Data.SqlTypes/SqlVector.xml Added documentation for CreateNull and removed old constructor docs.
doc/snippets/Microsoft.Data.SqlClient/SqlCommand.xml Clarified that SqlParameter.Size is ignored for vector types.
Comments suppressed due to low confidence (3)

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

  • [nitpick] The field name sizeInbytes does not follow camelCase conventions (sizeInBytes) and is now unused in tests. Consider renaming to sizeInBytes or removing this dead field to improve readability.
        public static float[] testData = new float[] { 1.1f, 2.2f, 3.3f };

doc/snippets/Microsoft.Data.SqlTypes/SqlVector.xml:12

  • [nitpick] The XML element tags for the constructors appear misaligned—there is a closing </ctor1> without a matching <ctor1> and missing <ctor2> tag. Please verify that constructor documentation tags are properly opened and closed.
    </ctor1>

src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlDataReader.cs:3366

  • The special handling for non-null vectors was removed, so all vector string conversions now return the raw SqlString. This breaks the expected JSON-style output for non-null vectors. Reintroduce the null check and call data.GetSqlVector<float>().GetString() when !data.IsNull.
                    if (typeof(T) == typeof(string) && metaData.metaType.SqlDbType == SqlDbTypeExtensions.Vector)

@apoorvdeshmukh apoorvdeshmukh added this to the 6.1.0 milestone Jul 11, 2025
@apoorvdeshmukh apoorvdeshmukh added the Area\Vector Use this for issues that are targeted for the Vector feature in the driver. label Jul 11, 2025
@apoorvdeshmukh apoorvdeshmukh self-assigned this Jul 11, 2025
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.

One typo in a doc comment.

@paulmedynski
Copy link
Contributor

/azp run

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

Copy link

codecov bot commented Jul 11, 2025

Codecov Report

Attention: Patch coverage is 81.25000% with 3 lines in your changes missing coverage. Please review.

Please upload report for BASE (release/6.1@3396340). Learn more about missing BASE report.

Files with missing lines Patch % Lines
...qlClient/src/Microsoft/Data/SqlClient/SqlBuffer.cs 0.00% 1 Missing ⚠️
...ient/src/Microsoft/Data/SqlClient/SqlDataReader.cs 0.00% 1 Missing ⚠️
...lient/src/Microsoft/Data/SqlClient/SqlParameter.cs 80.00% 1 Missing ⚠️
Additional details and impacted files
@@              Coverage Diff               @@
##             release/6.1    #3472   +/-   ##
==============================================
  Coverage               ?   68.91%           
==============================================
  Files                  ?      280           
  Lines                  ?    62322           
  Branches               ?        0           
==============================================
  Hits                   ?    42947           
  Misses                 ?    19375           
  Partials               ?        0           
Flag Coverage Δ
addons 92.58% <ø> (?)
netcore 72.79% <81.25%> (?)
netfx 68.05% <81.25%> (?)

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.

@apoorvdeshmukh apoorvdeshmukh merged commit 6773a65 into release/6.1 Jul 12, 2025
129 checks passed
@apoorvdeshmukh apoorvdeshmukh deleted the dev/ad/port3468 branch July 12, 2025 06:34
@David-Engel David-Engel changed the title Port #3468 from main to 6.1 Backport 6.1 | API enhancements for vector datatype Jul 14, 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.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants