-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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: Stop nesting results in an extra JSON object #25527
Comments
Note: breaking change because it impacts raw queries. |
This creates issues since subqueries need to project out the bare object, rather than an object wrapping the object (interferes with query). We could have different logic for top-level projections (which are processed by the shaper) and subquery projections (which aren't), but we really should just do the right thing. |
Example test for trivial scalar projection, NorthwindSelectQueryTestBase.Select_scalar: public virtual Task Select_scalar(bool async)
=> AssertQuery(
async,
ss => ss.Set<Customer>().Select(c => c.City)); Currently-generated NoSQL: SELECT c["City"]
FROM root c
WHERE (c["Discriminator"] = "Customer") Cosmos results:
Proposed NoSQL: SELECT VALUE c["City"]
FROM root c
WHERE (c["Discriminator"] = "Customer") Cosmos results:
|
And the same thing for a structural type projected out of the database, NorthwindSelectQueryTestBase.Select_customer_identity: public virtual Task Select_customer_identity(bool async)
=> AssertQuery(
async,
ss => ss.Set<Customer>().Select(c => c)); Currently-generated NoSQL: SELECT c
FROM root c
WHERE (c["Discriminator"] = "Customer") Cosmos results:
Proposed NoSQL: SELECT VALUE c
FROM root c
WHERE (c["Discriminator"] = "Customer") Cosmos results:
|
Closes dotnet#25527 Reimplement via ProjectionExpression.IsValueProjection Materializer changes. Revert "Update dependencies from https://github.com/dotnet/runtime build 20240602.3 (dotnet#33880)" This reverts commit c7f369c.
Note: Cosmos automatically filters out The undefined filtering behavior makes sense when you consider that JSON properties may or may not exist; for example, if you project out property Foo of all documents, and some documents don't have that property, then those documents would get naturally filtered out of the results. However, this is a bit more problematic in other cases where undefined is returned. For example, many functions return undefined when given a null argument, e.g. project out the first character of some property. This returns undefined where the property is null (not undefined!), and therefore would filter out those documents as well. This causes a behavioral divergence with the LINQ-to-Objects evaluation, where you'd get a NullReferenceExpression (but at least no silent dropping of data). We discussed this with the Cosmos team and decided to keep the Cosmos "native" or expecetd behavior, i.e. to project out using VALUE despite the undefined filtering behavior. Wrapping with an object could be worse performance-wise, and is generally not the expected/natural way to query Cosmos. |
Closes dotnet#25527 Co-Authored-By: Arthur Vickers <[email protected]>
Our basic Cosmos query looks like this:
This produces results such as the following:
Instead, we could generate the following simpler star-based query:
Which produces:
The text was updated successfully, but these errors were encountered: