-
Notifications
You must be signed in to change notification settings - Fork 330
Add float16 vector backward compatibility tests and refactor float32 vectors as varchar(max) test suite. #4234
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
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
3ca7713
Refactor testsuite for testing float32 vectors as varchar(max)
apoorvdeshmukh bfbe6ae
Add testcases for testing float16 vectors as varchar
apoorvdeshmukh a499f8d
Refine testcases
apoorvdeshmukh e210068
Update float16 vector support probe comment
apoorvdeshmukh 67ca21b
Avoid test duplication and use RAII classes
apoorvdeshmukh da25386
Remove vector-feature.instructions file
apoorvdeshmukh 92a1958
Merge remote-tracking branch 'origin/main' into dev/ad/vector16-bc
apoorvdeshmukh File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
106 changes: 106 additions & 0 deletions
106
...SqlClient/tests/ManualTests/SQL/VectorTest/Float16VectorTypeBackwardCompatibilityTests.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,106 @@ | ||
| // Licensed to the .NET Foundation under one or more agreements. | ||
| // The .NET Foundation licenses this file to you under the MIT license. | ||
| // See the LICENSE file in the project root for more information. | ||
|
|
||
| using System.Collections.Generic; | ||
| using System.Text.Json; | ||
| using System.Threading.Tasks; | ||
| using Xunit; | ||
| using Xunit.Abstractions; | ||
|
|
||
| namespace Microsoft.Data.SqlClient.ManualTesting.Tests.SQL.VectorTest | ||
| { | ||
| /// <summary> | ||
| /// Provides parameterized test data for backward compatibility tests that exchange | ||
| /// float16 vector data as varchar(max) JSON strings. | ||
| /// </summary> | ||
| public static class Float16VarcharVectorTestData | ||
| { | ||
| // Values chosen to be exactly representable in IEEE-754 binary16 (float16), | ||
| // so JSON round-trips through a vector(N, float16) column without precision loss. | ||
| public static readonly float[] TestData = { 1.0f, 2.0f, 3.0f }; | ||
|
|
||
| /// <summary> | ||
| /// Generates test cases for all 4 SqlParameter construction patterns x 2 value types (non-null + null). | ||
| /// Each case yields: [int pattern, string jsonOrNull, float[] expectedData] | ||
| /// where jsonOrNull is null when testing DBNull insertion. | ||
| /// </summary> | ||
| public static IEnumerable<object[]> GetVarcharVectorInsertTestData() | ||
| { | ||
| string json = JsonSerializer.Serialize(TestData); | ||
|
|
||
| // Pattern 1-4 with non-null JSON value | ||
| yield return new object[] { 1, json, TestData }; | ||
| yield return new object[] { 2, json, TestData }; | ||
| yield return new object[] { 3, json, TestData }; | ||
| yield return new object[] { 4, json, TestData }; | ||
|
|
||
| // Pattern 1-4 with null value | ||
| yield return new object[] { 1, null, null }; | ||
| yield return new object[] { 2, null, null }; | ||
| yield return new object[] { 3, null, null }; | ||
| yield return new object[] { 4, null, null }; | ||
| } | ||
| } | ||
|
|
||
| public sealed class Float16VectorTypeBackwardCompatibilityTests : VectorBackwardCompatTestBase | ||
| { | ||
| public Float16VectorTypeBackwardCompatibilityTests(ITestOutputHelper output) | ||
| : base(output, columnDefinition: "vector(3, float16)", namePrefix: "VectorF16") | ||
| { | ||
| } | ||
|
|
||
| protected override float[] GetPrepareTestValues(int i) => | ||
| new float[] { i + 1, i + 2, i + 3 }; | ||
|
|
||
| #region Insert Tests | ||
|
|
||
| [ConditionalTheory(typeof(DataTestUtility), nameof(DataTestUtility.AreConnStringsSetup), nameof(DataTestUtility.IsSqlVectorFloat16Supported))] | ||
| [MemberData(nameof(Float16VarcharVectorTestData.GetVarcharVectorInsertTestData), MemberType = typeof(Float16VarcharVectorTestData), DisableDiscoveryEnumeration = true)] | ||
| public void TestVectorDataInsertionAsVarchar(int pattern, string jsonValue, float[] expectedData) | ||
| => InsertAndValidateAsVarchar(pattern, jsonValue, expectedData); | ||
|
|
||
| [ConditionalTheory(typeof(DataTestUtility), nameof(DataTestUtility.AreConnStringsSetup), nameof(DataTestUtility.IsSqlVectorFloat16Supported))] | ||
| [MemberData(nameof(Float16VarcharVectorTestData.GetVarcharVectorInsertTestData), MemberType = typeof(Float16VarcharVectorTestData), DisableDiscoveryEnumeration = true)] | ||
| public async Task TestVectorDataInsertionAsVarcharAsync(int pattern, string jsonValue, float[] expectedData) | ||
| => await InsertAndValidateAsVarcharAsync(pattern, jsonValue, expectedData); | ||
|
|
||
| #endregion | ||
|
|
||
| #region Stored Procedure Tests | ||
|
|
||
| [ConditionalFact(typeof(DataTestUtility), nameof(DataTestUtility.AreConnStringsSetup), nameof(DataTestUtility.IsSqlVectorFloat16Supported))] | ||
| public void TestStoredProcParamsForVectorAsVarchar() | ||
| => StoredProcRoundTrip(Float16VarcharVectorTestData.TestData); | ||
|
|
||
| [ConditionalFact(typeof(DataTestUtility), nameof(DataTestUtility.AreConnStringsSetup), nameof(DataTestUtility.IsSqlVectorFloat16Supported))] | ||
| public async Task TestStoredProcParamsForVectorAsVarcharAsync() | ||
| => await StoredProcRoundTripAsync(Float16VarcharVectorTestData.TestData); | ||
|
|
||
| #endregion | ||
|
|
||
| #region Bulk Copy Tests | ||
|
|
||
| [ConditionalTheory(typeof(DataTestUtility), nameof(DataTestUtility.AreConnStringsSetup), nameof(DataTestUtility.IsSqlVectorFloat16Supported))] | ||
| [InlineData(1)] | ||
| [InlineData(2)] | ||
| public void TestSqlBulkCopyForVectorAsVarchar(int bulkCopySourceMode) | ||
| => BulkCopyRoundTrip(bulkCopySourceMode, Float16VarcharVectorTestData.TestData); | ||
|
|
||
| [ConditionalTheory(typeof(DataTestUtility), nameof(DataTestUtility.AreConnStringsSetup), nameof(DataTestUtility.IsSqlVectorFloat16Supported))] | ||
| [InlineData(1)] | ||
| [InlineData(2)] | ||
| public async Task TestSqlBulkCopyForVectorAsVarcharAsync(int bulkCopySourceMode) | ||
| => await BulkCopyRoundTripAsync(bulkCopySourceMode, Float16VarcharVectorTestData.TestData); | ||
|
|
||
| #endregion | ||
|
|
||
| #region Prepared Statement Tests | ||
|
|
||
| [ConditionalFact(typeof(DataTestUtility), nameof(DataTestUtility.AreConnStringsSetup), nameof(DataTestUtility.IsSqlVectorFloat16Supported))] | ||
| public void TestInsertVectorsAsVarcharWithPrepare() | ||
| => PreparedInsertRoundTrip(); | ||
|
|
||
| #endregion | ||
| } | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.