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

Project error when referencing $$ROOT in master

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 7.3.0-rc0
    • Affects Version/s: None
    • Component/s: None
    • Labels:
      None
    • Fully Compatible
    • ALL

      This ticket tracks the issue from SERVER-83502 for the master branch.

       


       

      Seeing the error "Cannot require both kResult and MakeResultInfo" when attempting to run queries with a second project stage referencing a newly created field in a stage ($project/$addFields). Related to ticket SERVER-81466 that changes project generation.

      Examples of queries that failed with this error (v7.2.0-rc1):

      Note: Running on v6.0.11 works as expected with no error.

      db.atlascoll.aggregate({ "$project": { "newfield1": "$$ROOT" } }, { "$project": { "newfield2": "$newfield1" } })
      
      db.atlascoll.aggregate({ "$addFields": { "newfield1": "$$ROOT" } }, { "$project": { "newfield2": "$newfield1" } })
      

      Examples of queries that completed successfully:

      db.atlascoll.aggregate({ "$project": { "newfield1": "$$ROOT" } }, { "$match": { "newfield1.a": 2 } }) - running a single $project followed by match
      db.atlascoll.aggregate({ "$project": { "newfield1": "$$ROOT" } }, { "$project": { "newfield2": "$$ROOT" } }) - running two projects with the second one also referencing $$ROOT
      db.atlascoll.aggregate({ "$project": { "newfield1": "$$NOW" } }, { "$project": { "newfield2": "$newfield1" } }) - running the same query but using the system var $$NOW instead
      db.atlascoll.aggregate({ "$addFields": { "newfield1": "$$ROOT" } }, { "$addFields": { "newfield2": "$newfield1" } }) - using addFields instead of project
      

      Some additional info in the slack thread here.

            Assignee:
            andrew.paroski@mongodb.com Drew Paroski
            Reporter:
            andrew.paroski@mongodb.com Drew Paroski
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: