Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ public SqlVector(System.ReadOnlyMemory<T> memory) { }
/// <include file='../../../../doc/snippets/Microsoft.Data.SqlTypes/SqlVector.xml' path='docs/members[@name="SqlVector"]/IsNull/*' />
public bool IsNull => throw null;
/// <include file='../../../../doc/snippets/Microsoft.Data.SqlTypes/SqlVector.xml' path='docs/members[@name="SqlVector"]/Null/*' />
public static SqlVector<T> Null => throw null;
public static SqlVector<T>? Null => throw null;
/// <include file='../../../../doc/snippets/Microsoft.Data.SqlTypes/SqlVector.xml' path='docs/members[@name="SqlVector"]/Length/*' />
public int Length { get { throw null; } }
/// <include file='../../../../doc/snippets/Microsoft.Data.SqlTypes/SqlVector.xml' path='docs/members[@name="SqlVector"]/Memory/*' />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2425,7 +2425,7 @@ public SqlVector(System.ReadOnlyMemory<T> memory) { }
/// <include file='../../../../doc/snippets/Microsoft.Data.SqlTypes/SqlVector.xml' path='docs/members[@name="SqlVector"]/IsNull/*' />
public bool IsNull => throw null;
/// <include file='../../../../doc/snippets/Microsoft.Data.SqlTypes/SqlVector.xml' path='docs/members[@name="SqlVector"]/Null/*' />
public static SqlVector<T> Null => throw null;
public static SqlVector<T>? Null => throw null;
/// <include file='../../../../doc/snippets/Microsoft.Data.SqlTypes/SqlVector.xml' path='docs/members[@name="SqlVector"]/Length/*' />
public int Length { get { throw null; } }
/// <include file='../../../../doc/snippets/Microsoft.Data.SqlTypes/SqlVector.xml' path='docs/members[@name="SqlVector"]/Memory/*' />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,11 +92,13 @@ public static class DataTestUtility
//SQL Server EngineEdition
private static string s_sqlServerEngineEdition;

// Currently, only Azure SQL supports vectors and JSON.
// Our CI images with specific SQL Server versions lag
// behind with vector and JSON support.
// JSON Column type
public static readonly bool IsJsonSupported = false;

public static readonly bool IsJsonSupported = !IsNotAzureServer();
// VECTOR column type
public static readonly bool IsVectorSupported = false;
public static readonly bool IsVectorSupported = !IsNotAzureServer();

// Azure Synapse EngineEditionId == 6
// More could be read at https://learn.microsoft.com/en-us/sql/t-sql/functions/serverproperty-transact-sql?view=sql-server-ver16#propertyname
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,9 @@
<Compile Include="SQL\DataSourceParserTest\DataSourceParserTest.cs" />
<Compile Include="SQL\InstanceNameTest\InstanceNameTest.cs" />
<Compile Include="SQL\IntegratedAuthenticationTest\IntegratedAuthenticationTest.cs" />
<Compile Include="SQL\JsonTest\JsonBulkCopyTest.cs" />
<Compile Include="SQL\JsonTest\JsonStreamTest.cs" />
<Compile Include="SQL\JsonTest\JsonTest.cs" />
<Compile Include="SQL\KerberosTests\KerberosTest.cs" />
<Compile Include="SQL\KerberosTests\KerberosTicketManager\KerberosTicketManager.cs" />
<Compile Include="SQL\LocalDBTest\LocalDBTest.cs" />
Expand Down Expand Up @@ -213,6 +216,9 @@
<Compile Include="SQL\UdtTest\UdtTest2.cs" />
<Compile Include="SQL\UdtTest\UdtTestHelpers.cs" />
<Compile Include="SQL\Utf8SupportTest\Utf8SupportTest.cs" />
<Compile Include="SQL\VectorTest\VectorTypeBackwardCompatibilityTests.cs" />
<Compile Include="SQL\VectorTest\NativeVectorFloat32Tests.cs" />
<Compile Include="SQL\VectorTest\VectorAPIValidationTest.cs" />
<Compile Include="SQL\WeakRefTest\WeakRefTest.cs" />
<Compile Include="SQL\WeakRefTestYukonSpecific\WeakRefTestYukonSpecific.cs" />
<Compile Include="SQL\ParameterTest\DateTimeVariantTest.cs" />
Expand Down Expand Up @@ -294,11 +300,6 @@
<Compile Include="SQL\Common\SystemDataInternals\TdsParserStateObjectHelper.cs" />
<Compile Include="SQL\ConnectionTestWithSSLCert\CertificateTest.cs" />
<Compile Include="SQL\ConnectionTestWithSSLCert\CertificateTestWithTdsServer.cs" />
<Compile Include="SQL\JsonTest\JsonBulkCopyTest.cs" />
<Compile Include="SQL\JsonTest\JsonStreamTest.cs" />
<Compile Include="SQL\JsonTest\JsonTest.cs" />
<Compile Include="SQL\VectorTest\VectorTypeBackwardCompatibilityTests.cs" />
<Compile Include="SQL\VectorTest\NativeVectorFloat32Tests.cs" />
<Compile Include="SQL\SqlCommand\SqlCommandStoredProcTest.cs" />
<Compile Include="TracingTests\TestTdsServer.cs" />
<Compile Include="XUnitAssemblyAttributes.cs" />
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
// 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;
using Microsoft.Data.SqlTypes;
using Xunit;

namespace Microsoft.Data.SqlClient.ManualTesting.Tests.SQL.VectorTest
{
public sealed class VectorAPIValidationTest
{
// We need this testcase to validate ref assembly for vector APIs
// Unit tests are covered under SqlVectorTest.cs
[Fact]
public void VectorAPITest()
{
// Validate that SqlVector<float> is a valid type and has valid SqlDbType
Assert.True(typeof(SqlVector<float>).IsValueType, "SqlVector<float> should be a value type.");
Assert.Equal(36, (int)SqlDbTypeExtensions.Vector);

// Validate ctor1 with float[] : public SqlVector(System.ReadOnlyMemory<T> memory) { }
var vector = new SqlVector<float>(VectorFloat32TestData.testData);
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: Sharing test data across classes like this can make it hard to update tests in the future. It's fine to replicate simple test data. This method could also be broken out into individual tests for the float[] constructor, ROM constructor, null vector, and create null method.

Copy link
Member

Choose a reason for hiding this comment

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

@apoorvdeshmukh please address this in 'main'. I will proceed with this PR in release/6.1 branch.

Assert.Equal(VectorFloat32TestData.testData, vector.Memory.ToArray());
Assert.Equal(3, vector.Length);

// Validate ctor2 with ReadOnlyMemory<T> : public SqlVector(ReadOnlyMemory<T> memory) { }
vector = new SqlVector<float>(new ReadOnlyMemory<float>(VectorFloat32TestData.testData));
Assert.Equal(VectorFloat32TestData.testData, vector.Memory.ToArray());
Assert.Equal(3, vector.Length);

//Validate IsNull property
Assert.False(vector.IsNull, "IsNull should be false for non-null vector.");

// Validate Null property returns null
Assert.Null(SqlVector<float>.Null);

//Validate length property
Assert.Equal(3, vector.Length);

// Validate CreateNull method
vector = SqlVector<float>.CreateNull(5);
Assert.True(vector.IsNull);
Assert.Equal(5, vector.Length);
}
}
}
Loading