Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-81502

$lookup with $documents and localField/foreignField fails to re-parse

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 7.2.0-rc0
    • Affects Version/s: None
    • Component/s: None
    • None
    • Query Integration
    • Fully Compatible
    • ALL

      The pipeline in this test case fails if we try to run $queryStats afterwards. It gives this error:

                  pymongo.errors.OperationFailure: PlanExecutor error during aggregation :: caused by :: Was not able to re-parse queryStats key when reading queryStats.Status Location40602: $queue is only valid as the first stage in a pipeline Hash: 9564851472401003349 Query Shape: { cmdNs: { db: "documents", coll: "lookup_coll" }, command: "aggregate", pipeline: [ { $lookup: { from: "$cmd.aggregate", as: "names", localField: "id_name", foreignField: "xx", let: {}, pipeline: [ { $queue: [ { ?: "?" } ] }, { $project: { _id: true, ed6595d4-e41d-438b-95ca-33d56d3b5ae5: { $const: [ { ?: "?" } ] } } }, { $unwind: { path: "$ed6595d4-e41d-438b-95ca-33d56d3b5ae5" } }, { $replaceRoot: { newRoot: "$ed6595d4-e41d-438b-95ca-33d56d3b5ae5" } } ] } }, { $match: { names: { $not: { $eq: [] } } } }, { $project: { _id: false } } ] }, full error: {'ok': 0.0, 'errmsg': 'PlanExecutor error during aggregation :: caused by :: Was not able to re-parse queryStats key when reading queryStats.Status Location40602: $queue is only valid as the first stage in a pipeline Hash: 9564851472401003349 Query Shape: { cmdNs: { db: "documents", coll: "lookup_coll" }, command: "aggregate", pipeline: [ { $lookup: { from: "$cmd.aggregate", as: "names", localField: "id_name", foreignField: "xx", let: {}, pipeline: [ { $queue: [ { ?: "?" } ] }, { $project: { _id: true, ed6595d4-e41d-438b-95ca-33d56d3b5ae5: { $const: [ { ?: "?" } ] } } }, { $unwind: { path: "$ed6595d4-e41d-438b-95ca-33d56d3b5ae5" } }, { $replaceRoot: { newRoot: "$ed6595d4-e41d-438b-95ca-33d56d3b5ae5" } } ] } }, { $match: { names: { $not: { $eq: [] } } } }, { $project: { _id: false } } ] }', 'code': 7349401, 'codeName': 'Location7349401'}
      

      The object in there is this:

      { cmdNs: 
          { db: "documents", coll: "lookup_coll" },
           command: "aggregate",
            pipeline: [
               { $lookup: {
                   from: "$cmd.aggregate", 
                   as: "names", 
                   localField: "id_name", 
                   foreignField: "xx", 
                   let: {}, 
                   pipeline: [ 
                      { $queue: [ { "?": "?" } ] },
                       { $project: { _id: true, "ed6595d4-e41d-438b-95ca-33d56d3b5ae5": { $const: [ { "?": "?" } ] } } },
                        { $unwind: { path: "$ed6595d4-e41d-438b-95ca-33d56d3b5ae5" } }, 
                        { $replaceRoot: { newRoot: "$ed6595d4-e41d-438b-95ca-33d56d3b5ae5" } } 
                      ] } },
                { $match: { names: { $not: { $eq: [] } } } },
                 { $project: { _id: false } } ] };
      

            Assignee:
            alyssa.clark@mongodb.com Alyssa Clark
            Reporter:
            charlie.swanson@mongodb.com Charlie Swanson
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: