[SERVER-57741] SBE should order projection fields ahead of expression fields in a $project stage Created: 16/Jun/21  Updated: 29/Oct/23  Resolved: 29/Jun/21

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

Type: Bug Priority: Major - P3
Reporter: Arun Banala Assignee: Mohammad Dashti (Inactive)
Resolution: Fixed Votes: 0
Labels: sbe-diff, sbe-post-v1, sbe-rollout
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Depends
Documented
is documented by DOCS-14609 [Server] Investigate changes in SERVE... Closed
Duplicate
is duplicated by SERVER-54582 Investigate modifying SBE projection ... Closed
Problem/Incident
Related
related to SERVER-54078 [SBE] Improve perf of the bestbuy_agg... Closed
Backwards Compatibility: Minor Change
Operating System: ALL
Sprint: Query Execution 2021-06-28, Query Execution 2021-07-12
Participants:
Linked BF Score: 148

 Description   

The behavior of $project in the classic engine is to order projection fields ahead of fields which require expression evaluation. SBE engine doesn't seemed to follow this convention, which is producing failures on the aggregation fuzzers. We should fix the behavior to match that of classic engine.



 Comments   
Comment by Vivian Ge (Inactive) [ 06/Oct/21 ]

Updating the fixversion since branching activities occurred yesterday. This ticket will be in rc0 when it’s been triggered. For more active release information, please keep an eye on #server-release. Thank you!

Comment by Githook User [ 29/Jun/21 ]

Author:

{'name': 'Mohammad Dashti', 'email': 'mdashti@gmail.com', 'username': 'mdashti'}

Message: SERVER-57741 Fixed SBE to order projection fields ahead of expression fields in a $project stage (to bring it closer to the behaviour of classic engine)
Branch: master
https://github.com/mongodb/mongo/commit/28812fce0bd40c9320740f0b9cbcb5f7b686eba7

Comment by Arun Banala [ 22/Jun/21 ]

mohammad.dashti That's the current behaviour in the classic engine. The projected fields are ordered first and in the order in which they appear in the underlying documents. Then the expression fields (the new fields to be added) are ordered in the way they appear in the specification.

Comment by Mohammad Dashti (Inactive) [ 22/Jun/21 ]

So if I have a document
Unknown macro: {a}
and do db.coll.find({}, {_id: 0, c: 1, b: 1, a: {$add: ["$a", 1]}}), the returning document should have a field order of b, c, a (still preserving the order of projection fields)?

This is a good question for arun.banala, regarding the expected behaviour for this issue, but your example is exactly how it's done in SERVER-54078 (i.e., for the projected fields, respects the order of fields in the source document rather than the order of fields in the query).

Comment by Ethan Zhang (Inactive) [ 22/Jun/21 ]

So if I have a document

{a: 1, b: 2, c: 3}

and do db.coll.find({}, {_id: 0, c: 1, b: 1, a: {$add: ["$a", 1]}}), the returning document should have a field order of b, c, a (still preserving the order of projection fields)?

Comment by Ethan Zhang (Inactive) [ 20/Jun/21 ]

We will talk about this in this week's Triage meeting.

Comment by Ethan Zhang (Inactive) [ 16/Jun/21 ]

This can address one of the issues that mohammad.dashti found in SERVER-54078
 

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