[SERVER-68516] [CQF] Always translate projections to ABT using ProjectionExecutor Created: 02/Aug/22  Updated: 29/Oct/23  Resolved: 18/Nov/22

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

Type: Task Priority: Major - P3
Reporter: Emily Wang (Inactive) Assignee: Ben Shteinfeld
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Depends
is depended on by SERVER-69231 Complete TODO listed in SERVER-68690 Closed
Related
is related to SERVER-70582 [CQF] Sampling CE may cause a MONGO_U... Closed
Backwards Compatibility: Fully Compatible
Sprint: QO 2022-10-03, QE 2022-10-17
Participants:

 Description   

This is an extension and continuation of SERVER-66846. The previous approach used a projection_executor, which we do not want to use in translating $project queries. SERVER-66846 only covers translating simple inclusion and exclusion projections from ProjectionAST. 

This ticket was originally intended to change all the projection translation code to use the ProjectionAST. However, while implementing that, we discovered that ProjectionAST has no way to represent $addFields and $replaceRoot projections, which already had test-only support in CQF via the ProjectionExecutor codepath. While ideally we use parse trees as input to ABT translation instead of runtime data structures, in this case we chose to be more pragmatic and exercise more of the optimizer's code sooner. In the future, the current ABT translation will be replaced with a proper BSON > CST {} > ABT translation; hence, we don't get much value out of moving to the ProjectionAST right now. As a result, we chose to repurpose this ticket to undo the changes in SERVER-66846 (with updates, as the revert is not clean).



 Comments   
Comment by Githook User [ 18/Nov/22 ]

Author:

{'name': 'Ben Shteinfeld', 'email': 'ben.shteinfeld@mongodb.com', 'username': 'bshteinfeld'}

Message: SERVER-68516 Revert back to always using `ProjectionExecutor` to translate projections to ABT

In SERVER-66846, we started using `ProjectionAST` as the input to ABT translations for inclusion/exclusion projections. SERVER-68516 was originally intended to update `$addFields` and `$replaceRoot` projections to also use the `ProjectionAST` codepath. However, we realized that `ProjectionAST` is not capable of representing these projections. So rather than losing functionality or maintaining two translation codepaths, we revert back to using `ProjectionExecutor` for translation.

Note this patch is not a clean revert of SERVER-66846. The diffs are:

  • Keeping the tests which the original commit introduced
  • Adding additional fallback logic for agg expressions and ensuring that the `_rootReplacementExpression` of a `ProjectionExecutor` is checked during the fallback mechanism. This was discovered because of a new test-case, added after SERVER-66846, for falling back to classic when a find query has a positional projection.
  • Updated comments
    Branch: master
    https://github.com/mongodb/mongo/commit/35c1d35f4870510bc0923e3db49eb026dcf93f32
Comment by Emily Wang (Inactive) [ 19/Aug/22 ]

Work done so far is Expression projections are implemented (including $slice and computedPaths), and $replaceRoot is implemented. $addFields is a work-in-progress (and also more complicated)

https://github.com/10gen/mongo/tree/emilywang/SERVER-68516

Comment by Emily Wang (Inactive) [ 17/Aug/22 ]

david.storch@mongodb.com I think this ticket was named badly – originally these features already existed and had corresponding tests, but because work in SERVER-66846 was split between some milestone 2 and 3 features, I split off this ticket. This ticket is just to add back all the existing features that was made unsupported in  SERVER-66846.

Comment by David Storch [ 16/Aug/22 ]

emily.wang@mongodb.com nicholas.zolnierz@mongodb.com this should probably not be housed in the ABT project, right? I'm assuming that we won't do this work just yet since it pertains to CQF milestone 3.

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