Skip to content

Use the proper type mapping for the result of AVG#35023

Merged
roji merged 2 commits intodotnet:mainfrom
ChrisJollyAU:cosmosavgtrunc
Oct 31, 2024
Merged

Use the proper type mapping for the result of AVG#35023
roji merged 2 commits intodotnet:mainfrom
ChrisJollyAU:cosmosavgtrunc

Conversation

@ChrisJollyAU
Copy link
Copy Markdown
Contributor

The translation of Average in Cosmos uses the same type mapping of its input for its return.

While this is fine if its input is a float, double, decimal, if you have an int or long as input it sets the return type as the same, thus causing a truncation when the results are read.

This fixes it by using the resultType passed in (the result type of the C# Average method - either float or double)

Fixes #26378

@ChrisJollyAU ChrisJollyAU requested a review from a team as a code owner October 31, 2024 09:43
Copy link
Copy Markdown
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.

@ChrisJollyAU thanks for fixing this!

I'm approving, but see my nit comment - will delay merging for that for now.

@roji roji enabled auto-merge (squash) October 31, 2024 10:58
@roji roji merged commit 507e7f1 into dotnet:main Oct 31, 2024
@ChrisJollyAU ChrisJollyAU deleted the cosmosavgtrunc branch October 31, 2024 14:29
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: Average truncates results

2 participants