Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Cosmos: Data corruption due to missing subquery pushdowns (block such scenarios) #34123

Closed
roji opened this issue Jun 29, 2024 · 0 comments · Fixed by #34255
Closed

Cosmos: Data corruption due to missing subquery pushdowns (block such scenarios) #34123

roji opened this issue Jun 29, 2024 · 0 comments · Fixed by #34255
Assignees
Labels
area-cosmos area-query breaking-change closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. type-bug type-enhancement
Milestone

Comments

@roji
Copy link
Member

roji commented Jun 29, 2024

Pushdown missing for Where over Skip/Take

For test NorthwindWhereQueryTestBase.Where_primitive:

public virtual Task Where_primitive(bool async)
    => AssertQueryScalar(
        async,
        ss => ss.Set<Employee>().Select(e => e.EmployeeID).Take(9).Where(i => i == 5));

Current SQL:

SELECT c["EmployeeID"]
FROM root c
WHERE ((c["Discriminator"] = "Employee") AND (c["EmployeeID"] = 5))
OFFSET 0 LIMIT @__p_0

This is incorrect, since the WHERE clause is evaluated before the OFFSET/LIMIT; composing the Where should cause a subquery pushdown (to be implemented in #33968.

Pushdown missing for Distinct over Skip/Take

Test NorthwindMiscellaneousQueryTestBase.Take_Distinct:

public virtual Task Take_Distinct(bool async)
    => AssertQuery(
        async,
        ss => ss.Set<Order>().OrderBy(o => o.OrderID).Take(5).Distinct());

Current SQL:

SELECT DISTINCT c
FROM root c
WHERE (c["Discriminator"] = "Order")
ORDER BY c["OrderID"]
OFFSET 0 LIMIT @__p_0

This is incorrect, since DISTINCT is evaluated before OFFSET/LIMIT.

@roji roji added this to the 9.0.0 milestone Jun 29, 2024
@roji roji self-assigned this Jun 29, 2024
@roji roji changed the title Cosmos: Data corruption due to incorrect translation of operators Cosmos: Data corruption due to not pushing down to subquery for Where Jun 29, 2024
@roji roji changed the title Cosmos: Data corruption due to not pushing down to subquery for Where Cosmos: Data corruption due to missing subquery pushdowns Jun 30, 2024
roji added a commit to roji/efcore that referenced this issue Jul 19, 2024
@roji roji added the closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. label Jul 19, 2024
roji added a commit to roji/efcore that referenced this issue Jul 19, 2024
@roji roji changed the title Cosmos: Data corruption due to missing subquery pushdowns Cosmos: Data corruption due to missing subquery pushdowns (block such scenarios) Jul 19, 2024
roji added a commit to roji/efcore that referenced this issue Jul 22, 2024
@roji roji closed this as completed in ca748dc Jul 22, 2024
@ajcvickers ajcvickers modified the milestones: 9.0.0, 9.0.0-rc1 Aug 21, 2024
@roji roji modified the milestones: 9.0.0-rc1, 9.0.0 Oct 12, 2024
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
area-cosmos area-query breaking-change closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. type-bug type-enhancement
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants