summaryrefslogtreecommitdiff
path: root/jstests/noPassthroughWithMongod
diff options
context:
space:
mode:
authorEric Cox <eric.cox@mongodb.com>2021-09-29 01:31:19 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2021-09-29 01:54:19 +0000
commit05dd4c09160867fc3e9ef370a8ba2991c883fe40 (patch)
tree7e366f98b994fbdfc17e7c58338a41928d9f497e /jstests/noPassthroughWithMongod
parent4c2c9d146bd7beb61a12c582c6d14f059fca06b1 (diff)
downloadmongo-05dd4c09160867fc3e9ef370a8ba2991c883fe40.tar.gz
SERVER-60282 Only pushdown $group stages when not merging
Diffstat (limited to 'jstests/noPassthroughWithMongod')
-rw-r--r--jstests/noPassthroughWithMongod/group_pushdown.js10
1 files changed, 10 insertions, 0 deletions
diff --git a/jstests/noPassthroughWithMongod/group_pushdown.js b/jstests/noPassthroughWithMongod/group_pushdown.js
index 628955dfb38..31d78bb4ce4 100644
--- a/jstests/noPassthroughWithMongod/group_pushdown.js
+++ b/jstests/noPassthroughWithMongod/group_pushdown.js
@@ -186,4 +186,14 @@ assertNoGroupPushdown(
coll,
[{$sortByCount: "$item"}],
[{"_id": "a", "count": 2}, {"_id": "b", "count": 2}, {"_id": "c", "count": 1}]);
+
+// When in a sharded environment or we are spilling $doingMerge is set to true. We should bail out
+// and not push down $group stages and the suffix of the pipeline when we encounter a $group stage
+// with this flag set.
+explain = coll.explain().aggregate([
+ {$group: {_id: "$item", s: {$sum: "$price"}}},
+ {$group: {_id: "$a", s: {$sum: "$b"}, $doingMerge: true}}
+]);
+assert.neq(null, getAggPlanStage(explain, "GROUP"), explain);
+assert(explain.stages[1].hasOwnProperty("$group"));
})();