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

Incorrect $mod aggregation expression results

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 7.3.0-rc0
    • Affects Version/s: 7.3.0-rc0
    • Component/s: Aggregation Framework
    • Labels:
      None
    • Query Optimization
    • Fully Compatible
    • ALL
    • Hide

       

      >db.c.insert({})
      >db.c.aggregate([{$project:{value: {$mod: [ NumberLong("314159265358979393"), 58529]}}}])
      Actual result: { "_id" : ObjectId("657c7e99af7f6fd9c0bf9a8f"), "value" : 31701 }
      Expected result: { "_id" : ObjectId("657c7e99af7f6fd9c0bf9a8f"), "value" : 31702 }

       

      Show
        >db.c.insert({}) >db.c.aggregate([{$project:{value: {$mod: [ NumberLong( "314159265358979393" ), 58529]}}}]) Actual result: { "_id" : ObjectId( "657c7e99af7f6fd9c0bf9a8f" ), "value" : 31701 } Expected result: { "_id" : ObjectId( "657c7e99af7f6fd9c0bf9a8f" ), "value" : 31702 }  
    • QO 2024-01-08, QO 2024-01-22
    • 114

      SERVER-39336 attempts to make $mod expression output to depend only on input types. However, the patch suffers from correctness problems when one input is NumberLong another NumberDouble and NumberLong value cannot be represented as a 64-bit integer without precision loss in a 64-bit float-point number. In the BF,         $mod (NumberLong("314159265358979393"), NumberDouble(58529)) results in incorrect value 31701, when the correct value is 31702.

            Assignee:
            james.harrison@mongodb.com James Harrison
            Reporter:
            mindaugas.malinauskas@mongodb.com Mindaugas Malinauskas
            Votes:
            0 Vote for this issue
            Watchers:
            8 Start watching this issue

              Created:
              Updated:
              Resolved: