[SERVER-74930] $avg is returning the sum instead of the average in aggregate $group Created: 15/Mar/23 Updated: 29/Oct/23 Resolved: 28/Mar/23 |
|
| Status: | Closed |
| Project: | Core Server |
| Component/s: | Aggregation Framework |
| Affects Version/s: | 6.0.5 |
| Fix Version/s: | 6.0.6 |
| Type: | Bug | Priority: | Critical - P2 |
| Reporter: | Jesse English | Assignee: | Adi Agrawal |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Assigned Teams: |
Query Execution
|
|||||||||||||||||||||||||||||||||
| Backwards Compatibility: | Fully Compatible | |||||||||||||||||||||||||||||||||
| Operating System: | ALL | |||||||||||||||||||||||||||||||||
| Steps To Reproduce: | Step 1: sample data points to use for reproducing this bug:
Step 2: the aggregate that fails to use the (last) $avg accurately:
Step 3: add in some non-$group aggregate command ahead of the last $group and the results are returned accurately:
|
|||||||||||||||||||||||||||||||||
| Sprint: | QE 2023-04-03 | |||||||||||||||||||||||||||||||||
| Participants: |
| Description |
|
When $avg-ing a field within a $group stage after several back-to-back $group aggregates, the aggregate is returning the sum of the field and not the average. Strangely enough, the $avg command will work on a multi-group aggregate, IF one inserts a non-$group command, (e.g. $sort, $match) before that last $group stage in which the $avg is taking place. |
| Comments |
| Comment by Githook User [ 28/Mar/23 ] |
|
Author: {'name': 'Adityavardhan Agrawal', 'email': 'adi.agrawal@mongodb.com', 'username': 'Adityav369'}Message: |
| Comment by Adi Agrawal [ 22/Mar/23 ] |
|
Hi jesse.english@eyesover.com and yuan.fang@mongodb.com , Thanks for sending this issue over. The failure happens in v6.0 on the slot based execution engine. This is not an issue in v6.2 and subsequent releases. It is fixed by We are working for a fix for v6.0 and will update this soon. Please reach out if you have any questions. Thanks again! |
| Comment by Yuan Fang [ 16/Mar/23 ] |
|
Hi jesse.english@eyesover.com, Thank you for your report. I was able to reproduce the issue you observed in v6.0.5, and I'm passing this along to the team for further investigation. Please continue to watch for updates. Regards, |