Skip to content

Commit

Permalink
SERVER-86224 Preserve bitmap slot when clearing non-requested fields …
Browse files Browse the repository at this point in the history
…(#18714)

GitOrigin-RevId: 8f6c489e72b413b3daaee5bec56c5dfb345262b9
  • Loading branch information
albymassari authored and MongoDB Bot committed Feb 6, 2024
1 parent f6339ef commit 2273889
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
14 changes: 14 additions & 0 deletions jstests/core/timeseries/timeseries_computed_field.js
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,20 @@ TimeseriesTest.run((insert) => {
assert.eq(res[2], {"obj": {}}, res);
}

{
// Try a replaceRoot stage which remove all fields.
const res = coll.aggregate([
{$match: {"time": {$gte: new Date(datePrefix + 200)}}},
{$addFields: {}},
{$project: {"measurement0": {$floor: "$topLevelScalar"}}},
{$replaceRoot: {newRoot: {}}}
])
.toArray();
assert.eq(res.length, 2, res);
assert.eq(res[0], {}, res);
assert.eq(res[1], {}, res);
}

{
const res = coll.aggregate([{
"$project": {
Expand Down
6 changes: 6 additions & 0 deletions src/mongo/db/query/sbe_stage_builder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -496,6 +496,12 @@ std::vector<PlanStageSlots::OwnedSlotName> PlanStageSlots::getRequiredNamesInOrd
std::vector<OwnedSlotName> names(reqs._data->slotNameSet.begin(),
reqs._data->slotNameSet.end());

// Always treat as required, if it present, the slot holding the bitmap with the filtered items
// of block values.
if (has(kBlockSelectivityBitmap)) {
names.emplace_back(kBlockSelectivityBitmap);
}

// If this PlanStageSlots has ResultInfo and 'reqs.hasResult()' is true, then we need
// to get the list of changed fields and add them to 'names'.
if (reqs.hasResult() && hasResultInfo()) {
Expand Down

0 comments on commit 2273889

Please sign in to comment.