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

Project error when referencing $$ROOT on v7.2.0-rc1

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

      Connect via mongosh running on MongoDB 7.2.0-rc1 and run the failing queries from the description.

      Show
      Connect via mongosh running on MongoDB 7.2.0-rc1 and run the failing queries from the description.
    • QE 2023-12-11

      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:
            ann.wang@mongodb.com Ann Wang
            Votes:
            0 Vote for this issue
            Watchers:
            8 Start watching this issue

              Created:
              Updated:
              Resolved: