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

Add test coverage for $in matching against +/-NaN

    XMLWordPrintable

    Details

    • Type: Task
    • Status: Closed
    • Priority: Major - P3
    • Resolution: Fixed
    • Affects Version/s: 5.0.0-rc6
    • Fix Version/s: 5.1.0-rc0
    • Component/s: None
    • Backwards Compatibility:
      Fully Compatible
    • Sprint:
      QE 2021-08-23, QE 2021-09-06
    • Linked BF Score:
      28

      Description

      Here are the steps to reproduce the issue:

       
      > db.fuzzer_coll.drop();
      true
       
      > const documentList = [
      ...     {_id: 0, "str": "Soap", "num": NumberInt(26549), "array": [{_id: 3, "str": NaN, "num": NumberLong("43418") }], }, // 0
      ...     {_id: 729, "str": "pricing structure", "num": NumberLong("360"), "obj": {_id: 733, "num": NaN, "obj": {}, }, }, // 129
      ... ];
       
      > db.fuzzer_coll.insert(documentList);
      BulkWriteResult({
      	"writeErrors" : [ ],
      	"writeConcernErrors" : [ ],
      	"nInserted" : 2,
      	"nUpserted" : 0,
      	"nMatched" : 0,
      	"nModified" : 0,
      	"nRemoved" : 0,
      	"upserted" : [ ]
      })
       
      > // using the classic engine
      > db.adminCommand({setParameter: 1, internalQueryEnableSlotBasedExecutionEngine: false})
      { "was" : false, "ok" : 1 }
      > db.fuzzer_coll.aggregate([{$sort: {_id: 1}}, {$graphLookup: {from: "fuzzer_coll", startWith: ["$obj.obj.str", NumberDecimal("-NaN")], connectFromField: "obj.obj.obj.obj", connectToField: "obj.num", as: "array", maxDepth: 1, depthField: "obj.obj.obj.num"}}])
      { "_id" : 0, "str" : "Soap", "num" : 26549, "array" : [ { "_id" : 0, "str" : "Soap", "num" : 26549, "array" : [ { "_id" : 3, "str" : NaN, "num" : NumberLong(43418) } ], "obj" : { "obj" : { "obj" : { "num" : NumberLong(0) } } } }, { "_id" : 729, "str" : "pricing structure", "num" : NumberLong(360), "obj" : { "_id" : 733, "num" : NaN, "obj" : { "obj" : { "num" : NumberLong(0) } } } } ] }
      { "_id" : 729, "str" : "pricing structure", "num" : NumberLong(360), "obj" : { "_id" : 733, "num" : NaN, "obj" : {  } }, "array" : [ { "_id" : 0, "str" : "Soap", "num" : 26549, "array" : [ { "_id" : 3, "str" : NaN, "num" : NumberLong(43418) } ], "obj" : { "obj" : { "obj" : { "num" : NumberLong(0) } } } }, { "_id" : 729, "str" : "pricing structure", "num" : NumberLong(360), "obj" : { "_id" : 733, "num" : NaN, "obj" : { "obj" : { "num" : NumberLong(0) } } } } ] }
       
      > // using SBE
      > db.adminCommand({setParameter: 1, internalQueryEnableSlotBasedExecutionEngine: true})
      { "was" : false, "ok" : 1 }
      > db.fuzzer_coll.aggregate([{$sort: {_id: 1}}, {$limit: 20}, {$graphLookup: {from: "fuzzer_coll", startWith: ["$obj.obj.str", NumberDecimal("-NaN")], connectFromField: "obj.obj.obj.obj", connectToField: "obj.num", as: "array", maxDepth: 1, depthField: "obj.obj.obj.num"}}])
      { "_id" : 0, "str" : "Soap", "num" : 26549, "array" : [ { "_id" : 0, "str" : "Soap", "num" : 26549, "array" : [ { "_id" : 3, "str" : NaN, "num" : NumberLong(43418) } ], "obj" : { "obj" : { "obj" : { "num" : NumberLong(0) } } } } ] }
      { "_id" : 729, "str" : "pricing structure", "num" : NumberLong(360), "obj" : { "_id" : 733, "num" : NaN, "obj" : {  } }, "array" : [ { "_id" : 0, "str" : "Soap", "num" : 26549, "array" : [ { "_id" : 3, "str" : NaN, "num" : NumberLong(43418) } ], "obj" : { "obj" : { "obj" : { "num" : NumberLong(0) } } } } ] }
      

      As you see, the output of SBE has fewer elements compared to the classic engine, which hints into the direction that the special values (e.g., NaN and non-existing fields) accessed from SBE by $graphLookup are treated differently compared to the classic engine.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              mihai.andrei Mihai Andrei
              Reporter:
              mohammad.dashti Mohammad Dashti
              Participants:
              Votes:
              0 Vote for this issue
              Watchers:
              8 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: