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

$densify use case can result in documents outside of range

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 7.2.0-rc0, 6.0.12, 7.0.4
    • Affects Version/s: 7.0.2, 6.0.11, 7.1.0
    • Component/s: None
    • None
    • Fully Compatible
    • ALL
    • v7.0, v6.0
    • Hide

       

      db.dropDatabase();
      
      const pipeline = [
        {"$densify": {
            "field": "num",
            "partitionByFields": [ "key" ],
            "range": {
              "step": 1,
              "bounds": [
                4,
                8
              ]
            }
        }},
        {$sort: { num: 1}},
        {$project: { _id: 0, num: 1 }}
      ];
      // Expected result set is [4,5,6,7].
      assert.eq(4, db.collection.aggregate(pipeline).itcount());
      
      db.collection.insertMany([
        {"key": 1,"num": 2},
        {"key": 1,"num": 4},  {"key": 1,"num": 6}
      ]);
      // Expected result set is [2,4,5,6,7]. Fails assert with a result set of [2,3,4,4,5,6,7].
      assert.eq(5, db.collection.aggregate(pipeline).itcount());
      Show
        db.dropDatabase(); const pipeline = [ { "$densify" : { "field" : "num" , "partitionByFields" : [ "key" ], "range" : { "step" : 1, "bounds" : [ 4, 8 ] } }}, {$sort: { num: 1}}, {$project: { _id: 0, num: 1 }} ]; // Expected result set is [4,5,6,7]. assert .eq(4, db.collection.aggregate(pipeline).itcount()); db.collection.insertMany([ { "key" : 1, "num" : 2}, { "key" : 1, "num" : 4}, { "key" : 1, "num" : 6} ]); // Expected result set is [2,4,5,6,7]. Fails assert with a result set of [2,3,4,4,5,6,7]. assert .eq(5, db.collection.aggregate(pipeline).itcount());
    • QI 2023-10-30

      Affects $densify stages that use both 'partitionByFields' and 'range', and for which values exist both below the range and matching the lower bound

            Assignee:
            james.wahlin@mongodb.com James Wahlin
            Reporter:
            james.wahlin@mongodb.com James Wahlin
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: