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

$merge with pipeline after $documents returns error

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Critical - P2 Critical - P2
    • 8.0.0-rc0, 7.3.2, 7.0.13, 6.0.17
    • Affects Version/s: 7.2.0
    • Component/s: None
    • None
    • Query Optimization
    • Fully Compatible
    • ALL
    • v7.3, v7.2, v7.0, v6.0
    • Hide
      db.aggregate([
       { "$documents": [{ a: 1 }] }, 
      { "$merge": { "into": "test", "whenMatched": [{$set: {new:true}}] }}
      ])
      

      >>

      {aggregate: 1}

      is not valid for '$set'; a collection is required.

      db.aggregate([
       { "$documents": [{ a: 1 }] }, 
      { "$merge": { "into": "test", "whenMatched": [] }}
      ])
      

      >>

      {aggregate: 1}

      is not valid for an empty pipeline.

      Show
      db.aggregate([ { "$documents" : [{ a: 1 }] }, { "$merge" : { "into" : "test" , "whenMatched" : [{$set: { new : true }}] }} ]) >> {aggregate: 1} is not valid for '$set'; a collection is required. db.aggregate([ { "$documents" : [{ a: 1 }] }, { "$merge" : { "into" : "test" , "whenMatched" : [] }} ]) >> {aggregate: 1} is not valid for an empty pipeline.
    • QO 2024-02-05, QO 2024-02-19, QO 2024-03-04, QO 2024-03-18, QO 2024-04-01

      Replicates on both replicaset and sharded clusters in 7.2.
      Works as expected in 7.0.
      On 7.0 sharded cluster there's another error "$documents must run on mongoS, but cannot :: caused by :: $merge must run on a shard".
      The scope of this ticket is replicaset since there's a regression

            Assignee:
            chii.huang@mongodb.com Chi-I Huang
            Reporter:
            kateryna.kamenieva@mongodb.com Katya Kamenieva
            Votes:
            1 Vote for this issue
            Watchers:
            20 Start watching this issue

              Created:
              Updated:
              Resolved: