[SERVER-63849] Classic engine may produce wrong field order for $project Created: 18/Feb/22  Updated: 06/Dec/22  Resolved: 22/Feb/22

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

Type: Bug Priority: Major - P3
Reporter: Dan Larkin-York Assignee: Backlog - Query Execution
Resolution: Won't Fix Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Attachments: File repro.js    
Assigned Teams:
Query Execution
Operating System: ALL
Participants:

 Description   

It's not exactly clear what the absolute minimal reproducer is here, but it seems that for certain combinations of arrays, sub-objects, and computed projections, the classic engine can produce output with fields reordered relative to their position in the inclusion projection.

For example, given an input document

{
  _id: 1,
  'array': [],
  'obj': {},
}

and pipeline

[{$project: {
  'array': [],
  'obj.array': []
}}]

we produce

{
  '_id': 1,
  'obj': {'array': []},
  'array': []
}

This problem seems to go back quite a long way (at least 4.2), but was recently surfaced by the aggregation_optimization_fuzzer in BF-24359 (it appears we do not have the same behavior in SBE).



 Comments   
Comment by Dan Larkin-York [ 22/Feb/22 ]

arun.banala Thank you for surfacing that. It appears you are right that the fix in TIG-3430 did not cover the optimization fuzzer, and I've filed TIG-3885 to make the change. Closing this ticket as Won't Fix.

Comment by Dan Larkin-York [ 18/Feb/22 ]

I've attached a reproducer that can be run as a no_passthrough test.

Generated at Thu Feb 08 05:58:50 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.