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

$setUnion does not descend into nested arrays

    XMLWordPrintableJSON

Details

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Minor - P4 Minor - P4
    • None
    • 2.6.5
    • Aggregation Framework
    • None
    • ALL
    • Hide

      Sample data:

      db.s.insert([{"a":1}, {"a":1}, {"a":2}, {"a":2}])

      db.s.aggregate([
      {$group:{"_id":"$a","s":{$push:"$a"}}},
      {$group:{"_id":null,"ds":{$push:"$s"}}},
      {$project:{"out":{$setUnion:"$ds"}}}])

      The expectation is:`out` to be an array [1,2]. But it does not perform any computation in these cases and returns the "ds" array as such.

      Show
      Sample data: db.s.insert([{"a":1}, {"a":1}, {"a":2}, {"a":2}]) db.s.aggregate([ {$group:{"_id":"$a","s":{$push:"$a"}}}, {$group:{"_id":null,"ds":{$push:"$s"}}}, {$project:{"out":{$setUnion:"$ds"}}}]) The expectation is:`out` to be an array [1,2]. But it does not perform any computation in these cases and returns the "ds" array as such.

    Description

      The $setUnion operator doesn't work as stated in the docs. It doesn't work when its input is a variable which is an array of arrays.

      Attachments

        Activity

          People

            Unassigned Unassigned
            BatScream BatScream [X]
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: