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

SBE $project aggregation $sqrt: {NaN} asserts but should return NaN

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 7.1.0-rc0
    • Affects Version/s: 6.3.0-rc0, 7.0.0-rc0, 7.1.0-rc0
    • Component/s: None
    • Labels:
      None
    • Query Execution
    • Fully Compatible
    • ALL

      Expected behavior of a query like this

      db.a.aggregate([{$project: {_id: 0, result: {$sqrt: [NaN]}}}]) 

      is to return the following for each document in the collection

      { "result" : NaN }

      This $project does not get pushed down to SBE until the SBE Pushdown feature (PM-3162), which is still in progress. Working on this feature, the above $project does get pushed down to SBE and fails with this assertion:

      uncaught exception: Error: command failed: {
         "ok" : 0,
         "errmsg" : "PlanExecutor error during aggregation :: caused by :: $sqrt's argument must be greater than or equal to 0",
         "code" : 7157710,
        "codeName" : "Location7157710"
      } with original command request: {
         "aggregate" : "sqrt",
         "pipeline" : [
                 {
                         "$project" : {
                                 "_id" : 0,
                                 "result" : {
                                         "$sqrt" : [
                                                 NaN
                                         ]
                                 }
                         }
                 }
         ],
         "cursor" : {
         },
         "lsid" : {
                 "id" : UUID("5494ede8-1225-47e6-9396-7975688eaf2a")
         }
      }
      

      This assertion was introduced in 6.3.0-rc0 by SERVER-71577.

            Assignee:
            adi.agrawal@mongodb.com Adi Agrawal
            Reporter:
            kevin.cherkauer@mongodb.com Kevin Cherkauer
            Votes:
            0 Vote for this issue
            Watchers:
            8 Start watching this issue

              Created:
              Updated:
              Resolved: