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

$avg can miss results from shards that return double values

    XMLWordPrintableJSON

Details

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Major - P3 Major - P3
    • None
    • None
    • Aggregation Framework
    • None
    • ALL

    Description

      If group gets a result from a shard that returns a long value, it will set totalType to NumberLong and may fail to include previously read double values when calculating the average.

      Test (based on other unit test base classes):

                  /* Router result for a double and a long. */
                  class DoubleLong : public TwoOperandBase {
                      BSONObj operand1() {
                          return BSON( "d" << BSON( "subTotal" << 5.0 << "count" << 2 ) );
                      }
                      BSONObj operand2() {
                          return BSON( "d" << BSON( "subTotal" << 6LL << "count" << 1 ) );
                      }
                      BSONObj expectedResult() { return BSON( "" << 11.0/3 ); }
                  };

      Actual result is 2.0 since the 5.0 value is not added to the total.

      Attachments

        Activity

          People

            aaron Aaron Staple
            aaron Aaron Staple
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: