Skip to content
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

Cosmos: translate Contains over subquery #33905

Merged
merged 1 commit into from
Jun 5, 2024
Merged

Conversation

roji
Copy link
Member

@roji roji commented Jun 4, 2024

NOTE: This PR is based on top of #33895, review 2nd commit only

This PR adds support for translating Contains over subquery in Cosmos:

public virtual Task Column_collection_Contains_over_subquery(bool async)
    => AssertQuery(
        async,
        ss => ss.Set<PrimitiveCollectionsEntity>().Where(c => c.Ints.Where(i => i > 1).Contains(11)));

The translation:

SELECT c
FROM root c
WHERE ((c["Discriminator"] = "PrimitiveCollectionsEntity") AND EXISTS (
    SELECT 1
    FROM i IN c["Ints"]
    WHERE ((i > 1) AND (i = 11))))

Note that the Cosmos SDK provider translates differently:

SELECT VALUE root FROM root JOIN (SELECT VALUE ARRAY(SELECT VALUE i0 FROM root JOIN i0 IN root[\"Ints\"] WHERE (i0 > 3))) AS v0 WHERE ARRAY_CONTAINS(v0, 3)

We can treat our translation as temporary (and merge it), I'll clear it with the Cosmos team later for perf etc.

@roji roji requested a review from a team June 4, 2024 20:29
@roji roji enabled auto-merge (squash) June 5, 2024 13:59
@roji roji merged commit 27ce95b into dotnet:main Jun 5, 2024
7 checks passed
@roji roji deleted the InWithSubquery branch June 5, 2024 14:50
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