Skip to content

Commit ac58a1f

Browse files
Port vector ref assembly fixes and enable vector and json tests (#3562)
1 parent a5196ea commit ac58a1f

File tree

5 files changed

+60
-10
lines changed

5 files changed

+60
-10
lines changed

src/Microsoft.Data.SqlClient/netcore/ref/Microsoft.Data.SqlClient.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ public SqlVector(System.ReadOnlyMemory<T> memory) { }
131131
/// <include file='../../../../doc/snippets/Microsoft.Data.SqlTypes/SqlVector.xml' path='docs/members[@name="SqlVector"]/IsNull/*' />
132132
public bool IsNull => throw null;
133133
/// <include file='../../../../doc/snippets/Microsoft.Data.SqlTypes/SqlVector.xml' path='docs/members[@name="SqlVector"]/Null/*' />
134-
public static SqlVector<T> Null => throw null;
134+
public static SqlVector<T>? Null => throw null;
135135
/// <include file='../../../../doc/snippets/Microsoft.Data.SqlTypes/SqlVector.xml' path='docs/members[@name="SqlVector"]/Length/*' />
136136
public int Length { get { throw null; } }
137137
/// <include file='../../../../doc/snippets/Microsoft.Data.SqlTypes/SqlVector.xml' path='docs/members[@name="SqlVector"]/Memory/*' />

src/Microsoft.Data.SqlClient/netfx/ref/Microsoft.Data.SqlClient.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2425,7 +2425,7 @@ public SqlVector(System.ReadOnlyMemory<T> memory) { }
24252425
/// <include file='../../../../doc/snippets/Microsoft.Data.SqlTypes/SqlVector.xml' path='docs/members[@name="SqlVector"]/IsNull/*' />
24262426
public bool IsNull => throw null;
24272427
/// <include file='../../../../doc/snippets/Microsoft.Data.SqlTypes/SqlVector.xml' path='docs/members[@name="SqlVector"]/Null/*' />
2428-
public static SqlVector<T> Null => throw null;
2428+
public static SqlVector<T>? Null => throw null;
24292429
/// <include file='../../../../doc/snippets/Microsoft.Data.SqlTypes/SqlVector.xml' path='docs/members[@name="SqlVector"]/Length/*' />
24302430
public int Length { get { throw null; } }
24312431
/// <include file='../../../../doc/snippets/Microsoft.Data.SqlTypes/SqlVector.xml' path='docs/members[@name="SqlVector"]/Memory/*' />

src/Microsoft.Data.SqlClient/tests/ManualTests/DataCommon/DataTestUtility.cs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,11 +92,13 @@ public static class DataTestUtility
9292
//SQL Server EngineEdition
9393
private static string s_sqlServerEngineEdition;
9494

95+
// Currently, only Azure SQL supports vectors and JSON.
96+
// Our CI images with specific SQL Server versions lag
97+
// behind with vector and JSON support.
9598
// JSON Column type
96-
public static readonly bool IsJsonSupported = false;
97-
99+
public static readonly bool IsJsonSupported = !IsNotAzureServer();
98100
// VECTOR column type
99-
public static readonly bool IsVectorSupported = false;
101+
public static readonly bool IsVectorSupported = !IsNotAzureServer();
100102

101103
// Azure Synapse EngineEditionId == 6
102104
// More could be read at https://learn.microsoft.com/en-us/sql/t-sql/functions/serverproperty-transact-sql?view=sql-server-ver16#propertyname

src/Microsoft.Data.SqlClient/tests/ManualTests/Microsoft.Data.SqlClient.ManualTesting.Tests.csproj

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,9 @@
185185
<Compile Include="SQL\DataSourceParserTest\DataSourceParserTest.cs" />
186186
<Compile Include="SQL\InstanceNameTest\InstanceNameTest.cs" />
187187
<Compile Include="SQL\IntegratedAuthenticationTest\IntegratedAuthenticationTest.cs" />
188+
<Compile Include="SQL\JsonTest\JsonBulkCopyTest.cs" />
189+
<Compile Include="SQL\JsonTest\JsonStreamTest.cs" />
190+
<Compile Include="SQL\JsonTest\JsonTest.cs" />
188191
<Compile Include="SQL\KerberosTests\KerberosTest.cs" />
189192
<Compile Include="SQL\KerberosTests\KerberosTicketManager\KerberosTicketManager.cs" />
190193
<Compile Include="SQL\LocalDBTest\LocalDBTest.cs" />
@@ -213,6 +216,9 @@
213216
<Compile Include="SQL\UdtTest\UdtTest2.cs" />
214217
<Compile Include="SQL\UdtTest\UdtTestHelpers.cs" />
215218
<Compile Include="SQL\Utf8SupportTest\Utf8SupportTest.cs" />
219+
<Compile Include="SQL\VectorTest\VectorTypeBackwardCompatibilityTests.cs" />
220+
<Compile Include="SQL\VectorTest\NativeVectorFloat32Tests.cs" />
221+
<Compile Include="SQL\VectorTest\VectorAPIValidationTest.cs" />
216222
<Compile Include="SQL\WeakRefTest\WeakRefTest.cs" />
217223
<Compile Include="SQL\WeakRefTestYukonSpecific\WeakRefTestYukonSpecific.cs" />
218224
<Compile Include="SQL\ParameterTest\DateTimeVariantTest.cs" />
@@ -294,11 +300,6 @@
294300
<Compile Include="SQL\Common\SystemDataInternals\TdsParserStateObjectHelper.cs" />
295301
<Compile Include="SQL\ConnectionTestWithSSLCert\CertificateTest.cs" />
296302
<Compile Include="SQL\ConnectionTestWithSSLCert\CertificateTestWithTdsServer.cs" />
297-
<Compile Include="SQL\JsonTest\JsonBulkCopyTest.cs" />
298-
<Compile Include="SQL\JsonTest\JsonStreamTest.cs" />
299-
<Compile Include="SQL\JsonTest\JsonTest.cs" />
300-
<Compile Include="SQL\VectorTest\VectorTypeBackwardCompatibilityTests.cs" />
301-
<Compile Include="SQL\VectorTest\NativeVectorFloat32Tests.cs" />
302303
<Compile Include="SQL\SqlCommand\SqlCommandStoredProcTest.cs" />
303304
<Compile Include="TracingTests\TestTdsServer.cs" />
304305
<Compile Include="XUnitAssemblyAttributes.cs" />
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
// Licensed to the .NET Foundation under one or more agreements.
2+
// The .NET Foundation licenses this file to you under the MIT license.
3+
// See the LICENSE file in the project root for more information.
4+
5+
using System;
6+
using Microsoft.Data.SqlTypes;
7+
using Xunit;
8+
9+
namespace Microsoft.Data.SqlClient.ManualTesting.Tests.SQL.VectorTest
10+
{
11+
public sealed class VectorAPIValidationTest
12+
{
13+
// We need this testcase to validate ref assembly for vector APIs
14+
// Unit tests are covered under SqlVectorTest.cs
15+
[Fact]
16+
public void VectorAPITest()
17+
{
18+
// Validate that SqlVector<float> is a valid type and has valid SqlDbType
19+
Assert.True(typeof(SqlVector<float>).IsValueType, "SqlVector<float> should be a value type.");
20+
Assert.Equal(36, (int)SqlDbTypeExtensions.Vector);
21+
22+
// Validate ctor1 with float[] : public SqlVector(System.ReadOnlyMemory<T> memory) { }
23+
var vector = new SqlVector<float>(VectorFloat32TestData.testData);
24+
Assert.Equal(VectorFloat32TestData.testData, vector.Memory.ToArray());
25+
Assert.Equal(3, vector.Length);
26+
27+
// Validate ctor2 with ReadOnlyMemory<T> : public SqlVector(ReadOnlyMemory<T> memory) { }
28+
vector = new SqlVector<float>(new ReadOnlyMemory<float>(VectorFloat32TestData.testData));
29+
Assert.Equal(VectorFloat32TestData.testData, vector.Memory.ToArray());
30+
Assert.Equal(3, vector.Length);
31+
32+
//Validate IsNull property
33+
Assert.False(vector.IsNull, "IsNull should be false for non-null vector.");
34+
35+
// Validate Null property returns null
36+
Assert.Null(SqlVector<float>.Null);
37+
38+
//Validate length property
39+
Assert.Equal(3, vector.Length);
40+
41+
// Validate CreateNull method
42+
vector = SqlVector<float>.CreateNull(5);
43+
Assert.True(vector.IsNull);
44+
Assert.Equal(5, vector.Length);
45+
}
46+
}
47+
}

0 commit comments

Comments
 (0)