-
Type: Bug
-
Resolution: Works as Designed
-
Priority: Major - P3
-
None
-
Affects Version/s: None
-
Component/s: None
-
Labels:None
-
Query Execution
-
ALL
-
QE 2024-01-08, QE 2024-01-22
When comparing two doubles, valueCompare will call compareDoubles in compare_numbers.h so two NaN's will compare equal to each other. https://github.com/mongodb/mongo/blob/e67290f658e1a8529935f3c842fe9c25ccf420bf/src/mongo/base/compare_numbers.h#L58
When using genericCompare<std::equal_to<>>, no special case exists for NaN when both values are doubles, so it will fall back to using operator== for doubles. This means that when using genericCompare, NaN != NaN.
https://github.com/mongodb/mongo/blob/e67290f658e1a8529935f3c842fe9c25ccf420bf/src/mongo/db/exec/sbe/vm/vm.h#L99