[SERVER-83785] Project error when referencing $$ROOT in master Created: 01/Dec/23  Updated: 28/Dec/23  Resolved: 28/Dec/23

Status: Closed
Project: Core Server
Component/s: None
Affects Version/s: None
Fix Version/s: 7.3.0-rc0

Type: Bug Priority: Major - P3
Reporter: Drew Paroski Assignee: Drew Paroski
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Depends
depends on SERVER-83782 Fix bugs with MakeResultInfo Closed
Backwards Compatibility: Fully Compatible
Operating System: ALL
Participants:

 Description   

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.


Generated at Thu Feb 08 06:53:08 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.