Skip to content

Conversation

@tvaron3
Copy link
Member

@tvaron3 tvaron3 commented Dec 3, 2025

Description

Adds the float16 datatype for the vector embedding policy and adds a test creating a policy for each data type

Copilot AI review requested due to automatic review settings December 3, 2025 16:09
@tvaron3 tvaron3 requested a review from a team as a code owner December 3, 2025 16:09
@github-actions github-actions bot added the Cosmos label Dec 3, 2025
Copilot finished reviewing on behalf of tvaron3 December 3, 2025 16:11
Copy link
Contributor

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 pull request adds support for the Float16 datatype in the vector embedding policy for Azure Cosmos DB containers.

Key Changes:

  • Added VectorDataTypeFloat16 constant for 16-bit floating point vector embeddings
  • Added comprehensive test coverage for all vector data types (float32, float16, int8, uint8)

Reviewed changes

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

File Description
sdk/data/azcosmos/vector_embedding_policy.go Adds the Float16 constant definition with appropriate documentation
sdk/data/azcosmos/emulator_cosmos_container_test.go Adds test function that validates container creation and property persistence for all vector data types including the new float16 type

Comment on lines +398 to +441
createdResp, err := database.CreateContainer(context.TODO(), properties, nil)
if err != nil {
t.Fatalf("Failed to create container with %s data type: %v", dt.name, err)
}

container, _ := database.NewContainer(containerID)
readResp, err := container.Read(context.TODO(), nil)
if err != nil {
t.Fatalf("Failed to read container: %v", err)
}

readProperties := readResp.ContainerProperties
if readProperties.VectorEmbeddingPolicy == nil {
t.Fatalf("Expected VectorEmbeddingPolicy to be set")
}

if len(readProperties.VectorEmbeddingPolicy.VectorEmbeddings) != 1 {
t.Fatalf("Expected 1 vector embedding, got %d", len(readProperties.VectorEmbeddingPolicy.VectorEmbeddings))
}

embedding := readProperties.VectorEmbeddingPolicy.VectorEmbeddings[0]
if embedding.DataType != dt.dataType {
t.Errorf("Expected data type %s, got %s", dt.dataType, embedding.DataType)
}

if embedding.Path != "/vector1" {
t.Errorf("Expected path /vector1, got %s", embedding.Path)
}

if embedding.Dimensions != 256 {
t.Errorf("Expected dimensions 256, got %d", embedding.Dimensions)
}

if embedding.DistanceFunction != VectorDistanceFunctionEuclidean {
t.Errorf("Expected distance function euclidean, got %s", embedding.DistanceFunction)
}

// Clean up
_, err = container.Delete(context.TODO(), nil)
if err != nil {
t.Fatalf("Failed to delete container %s: %v", containerID, err)
}

_ = createdResp // Avoid unused variable warning
Copy link

Copilot AI Dec 3, 2025

Choose a reason for hiding this comment

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

The variable createdResp is assigned but never used meaningfully. The comment // Avoid unused variable warning suggests this was done intentionally, but it would be cleaner to use the blank identifier _ at assignment: _, err := database.CreateContainer(...) instead of assigning to createdResp and then discarding it later.

Copilot uses AI. Check for mistakes.
@github-actions
Copy link

github-actions bot commented Dec 3, 2025

API Change Check

APIView identified API level changes in this PR and created the following API reviews

sdk/data/azcosmos

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant