[SERVER-70236] [CQF] Order of fields in output documents of computed projections/addFields changes in CQF Created: 05/Oct/22  Updated: 05/Dec/22

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

Type: Task Priority: Major - P3
Reporter: Hana Pearlman Assignee: Backlog - Query Optimization
Resolution: Unresolved Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related
related to SERVER-70234 [CQF] Order of fields in output docum... Closed
Assigned Teams:
Query Optimization
Participants:

 Description   

For $addFields:

Consider document

{ "_id" : 0, "c" : 1 }

and query

{$addFields: {d: {e: 2}, b: 3, a: {b: 4}}}

For classic, the order of fields in the output document is "c" followed by the added fields in the order specified by the addFields. For CQF, the order of fields in the output document is "c" followed by "b", then "a", then "d".

For computed projection mixed with simple inclusion:

Consider document

{_id: 0, a1: {b1: {c1: 1}}}

and query

{$project: {'a1.b1.c1': 1, a0: {b0: {c0: 'str'}}}}

For classic, the order of fields in the output document is "a1" followed by "a0". For CQF, the order of fields in the output document is "a0" followed by "a1". Something very similar happens with only computed projections (i.e., not mixed with simple inclusion)-- CQF orders the fields alphabetically, while classic orders them according to the projection spec.

Filed as one ticket because I think the root cause is similar.


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