diff options
author | Charlie Swanson <charlie.swanson@mongodb.com> | 2022-06-06 22:30:53 +0000 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2022-06-06 23:15:26 +0000 |
commit | 8a3af130c7dba9936b30e17d25dd52a5802658ad (patch) | |
tree | f93b7dad5876c1a605c8a4c79040266c93f1ab3c /jstests/noPassthroughWithMongod | |
parent | 9399a204b3e4e587b4499a259babee509ea2a557 (diff) | |
download | mongo-8a3af130c7dba9936b30e17d25dd52a5802658ad.tar.gz |
SERVER-66812 Fix bug with $group projection analysis
Diffstat (limited to 'jstests/noPassthroughWithMongod')
-rw-r--r-- | jstests/noPassthroughWithMongod/group_pushdown.js | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/jstests/noPassthroughWithMongod/group_pushdown.js b/jstests/noPassthroughWithMongod/group_pushdown.js index e541c2e2f75..a8b2df80620 100644 --- a/jstests/noPassthroughWithMongod/group_pushdown.js +++ b/jstests/noPassthroughWithMongod/group_pushdown.js @@ -295,6 +295,19 @@ assertGroupPushdown(coll, [{$group: {_id: {"i": "$item"}, s: {$sum: "$price"}}}], [{_id: {i: "a"}, s: 15}, {_id: {i: "b"}, s: 30}, {_id: {i: "c"}, s: 5}]); +// Test that we can push down a $group and a projection. +assertGroupPushdown( + coll, + [{$project: {_id: 0, item: 1, price: 1}}, {$group: {_id: {i: "$item"}, s: {$sum: "$price"}}}], + [{_id: {i: "a"}, s: 15}, {_id: {i: "b"}, s: 30}, {_id: {i: "c"}, s: 5}]); + +// Test that the results are as expected if the projection comes first and removes a field that the +// $group stage needs. +assertGroupPushdown( + coll, + [{$project: {_id: 0, item: 1}}, {$group: {_id: {i: "$item"}, s: {$sum: "$price"}}}], + [{_id: {i: "a"}, s: 0}, {_id: {i: "b"}, s: 0}, {_id: {i: "c"}, s: 0}]); + // Run a group with spilling on and check that $group is pushed down. assertGroupPushdown(coll, [{$group: {_id: "$item", s: {$sum: "$price"}}}], |