$avg can miss results from shards that return double values

XMLWordPrintableJSON

    • Type: Bug
    • Resolution: Done
    • Priority: Major - P3
    • None
    • Affects Version/s: None
    • Component/s: Aggregation Framework
    • None
    • ALL
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      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.

            Assignee:
            Aaron Staple (Inactive)
            Reporter:
            Aaron Staple (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved: