[SERVER-63753] Implement creating the final object for $lookup lowered into SBE Created: 16/Feb/22  Updated: 29/Oct/23  Resolved: 21/Mar/22

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

Type: Task Priority: Major - P3
Reporter: Irina Yatsenko (Inactive) Assignee: Nikita Lapkov (Inactive)
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Problem/Incident
Backwards Compatibility: Fully Compatible
Sprint: QE 2022-04-04, QE 2022-02-21, QE 2022-03-07, QE 2022-03-21
Participants:
Linked BF Score: 162

 Description   

This final stage is likely to be the same for all types of joins (NLJ, INLJ and HJ).

Be careful re paths in "as" field. The expected semantics are:

db.left.drop(); db.right.drop();
db.left.insertMany([
    { "a":1, "obj" : {b: 2 } }, 
    { "a":1, "obj" : {b: 2 } },
])
db.right.insertMany([
    { "z": 1},
])
> db.left.aggregate([{$lookup: {from: "right", localField: "a", foreignField: "z", as: "obj", pipeline: [{$project:{_id:0}}]}},{$project:{_id:0}}])
{ "a" : 1, "obj" : [ { "z" : 1 } ] }
{ "a" : 1, "obj" : [ { "z" : 1 } ] }
> db.left.aggregate([{$lookup: {from: "right", localField: "a", foreignField: "z", as: "obj.b", pipeline: [{$project:{_id:0}}]}},{$project:{_id:0}}])
{ "a" : 1, "obj" : { "b" : [ { "z" : 1 } ] } }
{ "a" : 1, "obj" : { "b" : [ { "z" : 1 } ] } }
> db.left.aggregate([{$lookup: {from: "right", localField: "a", foreignField: "z", as: "obj.obj", pipeline: [{$project:{_id:0}}]}},{$project:{_id:0}}])
{ "a" : 1, "obj" : { "b" : 2, "obj" : [ { "z" : 1 } ] } }
{ "a" : 1, "obj" : { "b" : 2, "obj" : [ { "z" : 1 } ] } }

And for paths with numeric components, these are treated as field names rather than indices into arrays.



 Comments   
Comment by Githook User [ 17/Mar/22 ]

Author:

{'name': 'Nikita Lapkov', 'email': 'nikita.lapkov@mongodb.com', 'username': 'laplab'}

Message: SERVER-63753 Translate $lookup result object creation in SBE
Branch: master
https://github.com/mongodb/mongo/commit/ccacb3cc2bf19368ef70f48fc09beb55d5a497ea

Comment by Githook User [ 16/Mar/22 ]

Author:

{'name': 'Max Hirschhorn', 'email': 'max.hirschhorn@mongodb.com', 'username': 'visemet'}

Message: Revert "SERVER-63753 Translate $lookup result object creation in SBE"

This reverts commit e09abbd7289641317d9e213204fb79731655e004.
Branch: master
https://github.com/mongodb/mongo/commit/3818135a1b201fc2fbb9286c14bafd88f159a08f

Comment by Githook User [ 15/Mar/22 ]

Author:

{'name': 'Nikita Lapkov', 'email': 'nikita.lapkov@mongodb.com', 'username': 'laplab'}

Message: SERVER-63753 Translate $lookup result object creation in SBE
Branch: master
https://github.com/mongodb/mongo/commit/e09abbd7289641317d9e213204fb79731655e004

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