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

XMLWordPrintableJSON

    • Type: Bug
    • Resolution: Won't Fix
    • Priority: Major - P3
    • None
    • Affects Version/s: 4.4.12
    • Component/s: None
    • 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 } ] }
    • None
    • 3
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      See the steps to reproduce.

            Assignee:
            Steve Tarzia
            Reporter:
            Alya Berciu
            Votes:
            0 Vote for this issue
            Watchers:
            8 Start watching this issue

              Created:
              Updated:
              Resolved: