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: Data corruption due to missing subquery pushdowns #34123

Open
roji opened this issue Jun 29, 2024 · 0 comments
Open

Cosmos: Data corruption due to missing subquery pushdowns #34123

roji opened this issue Jun 29, 2024 · 0 comments

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant