Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-30270

$sum should be null when no fields/non numeric are found

    • Type: Icon: Improvement Improvement
    • Resolution: Won't Fix
    • Priority: Icon: Minor - P4 Minor - P4
    • None
    • Affects Version/s: None
    • Component/s: Aggregation Framework
    • None
    • Query

      I am the original reporter that led to https://jira.mongodb.org/browse/DOCS-8996

      I believe that $sum should work this way as well.

      For example:

      db.some_collection.aggregate([{$group: {
      _id: null,
      average: {$avg: '$bad_field'},
      sum: {$sum: '$bad_field'},
      }}]);
      

      will return null for average, and 0 for sum. It should return null for sum.

      I'm a little surprised $sum was not updated when $avg was, and feel that this was an oversight.

      Thanks

      Ben

            Assignee:
            backlog-server-query Backlog - Query Team (Inactive)
            Reporter:
            nefiga Ben Rotz
            Votes:
            0 Vote for this issue
            Watchers:
            9 Start watching this issue

              Created:
              Updated:
              Resolved: