Skip to content

Cosmos: strip implicit casts to allow vector search over arrays#34437

Merged
roji merged 4 commits intodotnet:mainfrom
roji:CosmosVectorStuff
Aug 21, 2024
Merged

Cosmos: strip implicit casts to allow vector search over arrays#34437
roji merged 4 commits intodotnet:mainfrom
roji:CosmosVectorStuff

Conversation

@roji
Copy link
Copy Markdown
Member

@roji roji commented Aug 14, 2024

This is a targeted fix to Cosmos, to strip convert nodes out which represent implicit conversions.

I think we need to revisit our general casting/conversion strategy (across both Cosmos and relational), but this specific change makes sense to me...

@ajcvickers can you verify that all vector search tests now pass?

@roji roji requested a review from ajcvickers August 14, 2024 13:38
@ajcvickers
Copy link
Copy Markdown
Contributor

@roji This is now hacked to allow both arrays and read-only-memories without appropriate overloads or type mappings.

Copy link
Copy Markdown
Member Author

@roji roji left a comment

Choose a reason for hiding this comment

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

Your changes look OK, at least for now! See CI test failures, plus you have to approve it (it's my PR originally)

/// </summary>
public override JToken? GenerateJToken(object? value)
{
// This is a hack to allow both arrays and ROM types without different function overloads or type mappings.
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Doesn't actually seem all that hacky to me! We basically need to do ToArray() because the Cosmos SDK doesn't (yet) natively support ROM, right?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

It's hacky in the sense that a type mapping with a converter should always be able to pass its value to that converter, but in this case we're using the same type mapping for values that may or may not need converting.

@ajcvickers
Copy link
Copy Markdown
Contributor

@roji I tweaked the query changes to fix the failing tests. Can you have a quick look?

Copy link
Copy Markdown
Member Author

@roji roji left a comment

Choose a reason for hiding this comment

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

Thanks @ajcvickers, LGTM (up to you to approve).

Comment thread src/EFCore.Cosmos/Query/Internal/CosmosSqlTranslatingExpressionVisitor.cs Outdated
@roji roji enabled auto-merge (squash) August 21, 2024 13:53
@ajcvickers
Copy link
Copy Markdown
Contributor

/azp run

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 1 pipeline(s).

@roji roji merged commit 1979607 into dotnet:main Aug 21, 2024
@roji roji deleted the CosmosVectorStuff branch August 21, 2024 16:49
ajcvickers added a commit that referenced this pull request Aug 21, 2024
Fixes #34402

Co-authored-by: Arthur Vickers <ajcvickers@hotmail.com>
ajcvickers added a commit that referenced this pull request Aug 21, 2024
Fixes #34402

Co-authored-by: Arthur Vickers <ajcvickers@hotmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants