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

$match + $expr in nested pipeline fails to resolve variable definition on on mongos

    • Type: Icon: Bug Bug
    • Resolution: Won't Fix
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: 4.4.12
    • Component/s: None
    • Labels:
      None
    • ALL
    • Hide

      On a sharded cluster (with the coll collection unsharded), the following command fails with the messageĀ "Use of undefined variable: var":

      db.coll.insert({a: 1})
      db.coll.aggregate({$lookup: {from: "coll", as: "coll", let: {var: "$a"}, pipeline: [
                    {$unionWith: {coll: "coll", pipeline: [                         
                                 {$match: {$expr: {$eq: ["$a", "$$var"]}}}]}}]}})
      

      However, running this against a mongod returns:

      { "_id" : ObjectId("620bc09e443b85085d27efd5"), "a" : 1, "coll" : [ { "_id" : ObjectId("620bc09e443b85085d27efd5"), "a" : 1 }, { "_id" : ObjectId("620bc09e443b85085d27efd5"), "a" : 1 } ] }
      
      Show
      On a sharded cluster (with the coll collection unsharded), the following command fails with the messageĀ "Use of undefined variable: var": db.coll.insert({a: 1}) db.coll.aggregate({$lookup: {from: "coll", as: "coll", let: {var: "$a"}, pipeline: [ {$unionWith: {coll: "coll", pipeline: [ {$match: {$expr: {$eq: ["$a", "$$var"]}}}]}}]}}) However, running this against a mongod returns: { "_id" : ObjectId("620bc09e443b85085d27efd5"), "a" : 1, "coll" : [ { "_id" : ObjectId("620bc09e443b85085d27efd5"), "a" : 1 }, { "_id" : ObjectId("620bc09e443b85085d27efd5"), "a" : 1 } ] }

      See the steps to reproduce.

            Assignee:
            steve.tarzia@mongodb.com Steve Tarzia
            Reporter:
            alya.berciu@mongodb.com Alya Berciu
            Votes:
            0 Vote for this issue
            Watchers:
            8 Start watching this issue

              Created:
              Updated:
              Resolved: