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: Fixes around array projection #34061

Merged
merged 1 commit into from
Jun 24, 2024
Merged

Conversation

roji
Copy link
Member

@roji roji commented Jun 22, 2024

Along with #34008, this should complete the collection projection story (though I still have a few things left to investigate).

I'm not super happy with the way things work, but this is more or less aligned with the relational behavior, and mostly works... I can see potential for cleanup and improvements in the future, but I've already spent enough time on it...

Closes #33797

@roji roji requested a review from ajcvickers June 22, 2024 09:17
@roji roji force-pushed the CosmosProjectCollections branch from 4da4950 to 3fe7200 Compare June 22, 2024 15:05
Comment on lines +1792 to +1795
SELECT VALUE i
FROM i IN c["Ints"]),
Copy link
Member

Choose a reason for hiding this comment

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

Wasn't c["Ints"] a better translation?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, it was - this is the result of composing ToList() on top of a bare array (ToList() is one of the major things enabled by this PR)... This is actually quite complicated, since the CLR type of the array (int[]) can't just be cast (in the shaper) to a List<int>.

FWIW the same thing happens in relational - if you look at the SQL Server SQL baseline for this same test you'll see OUTER APPLY OPENJSON([p].[Ints]) AS [i], although we could have just projected [p].[Ints] directly and parsed the JSON... It's indeed an unfortunate edge-case - opened #34081 to track improving it across both relational and Cosmos.

@roji roji force-pushed the CosmosProjectCollections branch from 3fe7200 to 227fa59 Compare June 24, 2024 20:57
@roji roji enabled auto-merge (squash) June 24, 2024 20:57
@roji roji merged commit 93c77f5 into dotnet:main Jun 24, 2024
7 checks passed
@roji roji deleted the CosmosProjectCollections branch June 24, 2024 21:40
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.

Cosmos: Support projecting out (primitive) collections
2 participants