ProjectionExecutor incorrectly leaves tombstones when evaluating arrays

XMLWordPrintableJSON

    • Type: Bug
    • Resolution: Unresolved
    • Priority: Major - P3
    • None
    • Affects Version/s: None
    • Component/s: None
    • Query Execution
    • ALL
    • Query 2020-11-30, Query 2020-12-14, Query 2020-12-28, Query 2021-01-11, Query 2021-01-25, Query Execution 2021-03-08, Query Execution 2021-03-22
    • 0
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      The ProjectionExecutor code will leave behind a MISSING placeholder for each array element, when the projection path prefix is an array. The FastPathEligibleInclusionNode doesn't seem to produce the same issue, since it uses BSONObj. BSONObj doesn't have the tombstones issue.

      This can be fixed by returning an empty array if all the array elements have MISSING value here.

      > db.c.insert({arr: [0]})
      // This uses FastPathEligibleInclusionNode
      > db.c.aggregate([{$_internalInhibitOptimization: {}},{$project: {"arr.a" : 1}}, {$addFields: { "arr.val" : ""}}]) 
      { "_id" : ObjectId("5f5646abfb04e16296128f3f"), "arr" : [ ] }
      // This uses InclusionNode main path
      > db.c.aggregate([{$_internalInhibitOptimization: {}},{$project: {"arr.a" : 1, p: {$literal: 1}}}, {$addFields: { "arr.val" : ""}}]) 
      { "_id" : ObjectId("5f5646abfb04e16296128f3f"), "arr" : [ { "val" : "" } ], "p" : 1 }
      

            Assignee:
            [DO NOT USE] Backlog - Query Execution
            Reporter:
            Arun Banala
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated: