[SERVER-61868] $max accumulator with collation might produce incorrect result for NaN Created: 02/Dec/21 Updated: 29/Oct/23 Resolved: 07/Dec/21 |
|
| Status: | Closed |
| Project: | Core Server |
| Component/s: | None |
| Affects Version/s: | None |
| Fix Version/s: | 5.3.0, 5.2.0-rc2 |
| Type: | Bug | Priority: | Major - P3 |
| Reporter: | Irina Yatsenko (Inactive) | Assignee: | Irina Yatsenko (Inactive) |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Issue Links: |
|
||||||||
| Backwards Compatibility: | Fully Compatible | ||||||||
| Operating System: | ALL | ||||||||
| Backport Requested: |
v5.2
|
||||||||
| Steps To Reproduce: | Into a collection insert two documents: {n: NumberLong(98618)}, {n: NaN}, then run aggregate([\{$group: {_id: null, max: {$max:"$n}}}],{collation:{locale:"en"}}). In classic engine the result is "NumberLong(98618)" and in SBE it's NaN. The classic result is correct, because we consider NaN to be less than any long.
|
||||||||
| Sprint: | QE 2021-12-13 | ||||||||
| Participants: | |||||||||
| Linked BF Score: | 165 | ||||||||
| Comments |
| Comment by Githook User [ 15/Dec/21 ] |
|
Author: {'name': 'Irina Yatsenko', 'email': 'irina.yatsenko@mongodb.com', 'username': 'IrinaYatsenko'}Message: (cherry picked from commit 560421e00c89080b410469550618536897e4cabf) |
| Comment by Githook User [ 07/Dec/21 ] |
|
Author: {'name': 'Irina Yatsenko', 'email': 'irina.yatsenko@mongodb.com', 'username': 'IrinaYatsenko'}Message: |
| Comment by Irina Yatsenko (Inactive) [ 03/Dec/21 ] |
|
The original title of this ticket was: "Inconsistent comparison of number types between 'genericCompare' and 'compare3way'". However, the inconsistency between how 'genericCompare()' and 'compare3way()' treats NaN is by design because 'genericCompare' implements SBE's semantics for NaN and 'compare3way' implements MQL's semantics. The proper fix for $max (and $min) with collation to use compare3way rather than genericCompare. Updated the title to "$max with collation might produce incorrect result for NaN" |