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

    XMLWordPrintable

Details

    • Bug
    • Status: Closed
    • Major - P3
    • Resolution: Won't Fix
    • 4.4.12
    • None
    • 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 } ] }

    Description

      See the steps to reproduce.

      Attachments

        Activity

          People

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

            Dates

              Created:
              Updated:
              Resolved: