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

$lookup in SBE allows undefined localField values

    • Type: Icon: Bug Bug
    • Resolution: Duplicate
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: None
    • None
    • Query Execution
    • ALL

      In the classic engine, $lookup (specified with localField/foreignField syntax) fails when a local field is undefined:

       > db.foo.find()
      { "_id" : ObjectId("672b7fa1046b20cdaa4eba47"), "a" : undefined }
      > db.foo.aggregate([{$lookup: {from: "foo", localField: "a", foreignField: "a", as: "res"}}])
      uncaught exception: Error: command failed: {
              "ok" : 0,
              "errmsg" : "PlanExecutor error during aggregation :: caused by :: cannot compare to undefined",
              "code" : 2,
              "codeName" : "BadValue"
      }
      

      But with SBE enabled, this query succeeds:

      > db.foo.find()
      { "_id" : ObjectId("672b7fa1046b20cdaa4eba47"), "a" : undefined }
       > db.foo.aggregate([{$lookup: {from: "foo", localField: "a", foreignField: "a", as: "res"}}])
      { "_id" : ObjectId("672b7fa1046b20cdaa4eba47"), "a" : undefined, "res" : [ { "_id" : ObjectId("672b7fa1046b20cdaa4eba47"), "a" : undefined } ] }
      

            Assignee:
            Unassigned Unassigned
            Reporter:
            hana.pearlman@mongodb.com Hana Pearlman
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: