-
Type: Bug
-
Resolution: Duplicate
-
Priority: Major - P3
-
None
-
Affects Version/s: None
-
Component/s: None
-
None
-
ALL
-
$sum should behave consistently with other grouping operators, such as $avg, when applied against non-existing fields, but instead it manufactures bogus zero values and there is no simple way to work it around.
Mongo DB also won't process $cond or $ifNull with enclosed $sum (it really should strip off conditionals to get to the accumulators, but that's another issue), and applying something like $first, with enclosed $cond, with enclosed $sum won't generate errors, but will yield bogus results instead of returning the one and only sum of the result.
These aggregations mess up things like charts, where instead of missing data zeros are output, which is misleading.
- related to
-
SERVER-30270 $sum should be null when no fields/non numeric are found
- Closed