summaryrefslogtreecommitdiff
path: root/jstests
diff options
context:
space:
mode:
authorYoonsoo Kim <yoonsoo.kim@mongodb.com>2022-05-09 21:31:28 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2022-05-10 05:39:01 +0000
commit201d38029bc41c68045312bc411b70bb8ae5416b (patch)
tree09fd9ea5bde36348224abebc2011a4add29cf999 /jstests
parentcb28b28ae6639b498f7526ee67ed468e790034f6 (diff)
downloadmongo-201d38029bc41c68045312bc411b70bb8ae5416b.tar.gz
SERVER-65863 Have optimized _id expression(s) pushed down properly
(cherry picked from commit 7f55c457738556cf96236ef9c7aa4b30bbe07390)
Diffstat (limited to 'jstests')
-rw-r--r--jstests/noPassthroughWithMongod/group_pushdown.js8
1 files changed, 8 insertions, 0 deletions
diff --git a/jstests/noPassthroughWithMongod/group_pushdown.js b/jstests/noPassthroughWithMongod/group_pushdown.js
index 0f127a67792..adfeda64b74 100644
--- a/jstests/noPassthroughWithMongod/group_pushdown.js
+++ b/jstests/noPassthroughWithMongod/group_pushdown.js
@@ -296,6 +296,14 @@ assertResultsMatchWithAndWithoutGroupPushdown(
[{"_id": 1, "s": 2}, {"_id": 2, "s": 2}, {"_id": 4, "s": 1}],
2);
+// Verifies that an optimized expression can be pushed down.
+assertResultsMatchWithAndWithoutGroupPushdown(
+ coll,
+ // {"$ifNull": [1, 2]} will be optimized into just the constant 1.
+ [{$group: {_id: {"$ifNull": [1, 2]}, o: {$min: "$quantity"}}}],
+ [{"_id": 1, o: 1}],
+ 1);
+
// Run a group with a supported $stdDevSamp accumultor and check that it gets pushed down.
assertGroupPushdown(coll,
[{$group: {_id: "$item", s: {$stdDevSamp: "$quantity"}}}],