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

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

    XMLWordPrintableJSON

Details

    • Icon: Improvement Improvement
    • Resolution: Won't Fix
    • Icon: Minor - P4 Minor - P4
    • None
    • None
    • Aggregation Framework
    • None
    • Query

    Description

      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

      Attachments

        Activity

          People

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

            Dates

              Created:
              Updated:
              Resolved: