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

[release/9.0] Return null when the type is nullable for Cosmos Max/Min/Average #35216

Merged
merged 3 commits into from
Nov 27, 2024

Conversation

ajcvickers
Copy link
Contributor

Ports #35173
Fixes #35094

Description

Updates to the Cosmos query architecture regressed translation for aggregate functions where the return type is nullable.

Customer impact

Cosmos queries that use Min, Max, or Average and return a nullable type throw in EF8 if the set is empty. This is the correct behavior for non-nullable returns, but if possible we instead return null, which is a more useful behavior, aligns with relational, and is the behavior we had in EF8.

How found

Customer reported on 9.

Regression

Yes, from 8.

Testing

Existing tests fixes and new tests added.

Risk

Low and quirked.

)

* Return null when the type is nullable for Cosmos Max/Min/Average

Fixes #35094

This was a regression resulting from the major Cosmos query refactoring that happened in EF9. In EF8, the functions Min, Max, and Average would return null if the return type was nullable or was cast to a nullable when the collection is empty. In EF9, this started throwing, which is correct for non-nullable types, but a regression for nullable types.

* Added notes
@ajcvickers ajcvickers requested a review from a team November 26, 2024 17:34
@ajcvickers ajcvickers added this to the 9.0.x milestone Nov 26, 2024
@ajcvickers ajcvickers changed the title Return null when the type is nullable for Cosmos Max/Min/Average [release/9.0] Return null when the type is nullable for Cosmos Max/Min/Average Nov 26, 2024
@ajcvickers ajcvickers merged commit 59e92ae into release/9.0-staging Nov 27, 2024
7 checks passed
@ajcvickers ajcvickers deleted the Odium branch November 27, 2024 15:22
@AndriySvyryd AndriySvyryd modified the milestones: 9.0.x, 9.0.1 Feb 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants