Skip to content

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

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

Merged
merged 2 commits into from
Nov 26, 2024

Conversation

ajcvickers
Copy link
Contributor

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.

@ajcvickers ajcvickers requested a review from a team as a code owner November 21, 2024 15:23
Copy link
Member

@roji roji left a comment

Choose a reason for hiding this comment

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

LGTM but see comments/suggestions.

One thought - do we have tests where we do Min/Max/Average over a nullable value type, and where the database actually does contain a null (as opposed to an empty result set)? If not, it might be worth adding those, as especially in Cosmos the returns-null vs. returns-nothing are two very distinct cases.

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.
@ajcvickers
Copy link
Contributor Author

@roji Made some updates if you want to have another look.

@ajcvickers ajcvickers closed this Nov 26, 2024
@ajcvickers ajcvickers reopened this Nov 26, 2024
Copy link
Member

@roji roji left a comment

Choose a reason for hiding this comment

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

LGTM, am still a bit worried about the throw-on-null code we're removing in relational and Cosmos, but it all seems well-tested and we'll have 10 for users to test this on (we should avoid backporting that particular change).

@ajcvickers ajcvickers merged commit 20201da into main Nov 26, 2024
7 checks passed
@ajcvickers ajcvickers deleted the VoidBringers branch November 26, 2024 17:04
ajcvickers added a commit that referenced this pull request Nov 26, 2024
)

* 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 added a commit that referenced this pull request Nov 27, 2024
…n/Average (#35216)

* Return null when the type is nullable for Cosmos Max/Min/Average (#35173)

* 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

* Added quirks

* Fix tests.
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: Min/Max/Average over nullable value type throws on no data
2 participants