blob: 898ae799cdfd0f897d6f099db8c298ce25b43bc3 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
(function() {
"use strict";
const coll = db.id_meta_projection;
coll.drop();
assert.commandWorked(coll.insert({_id: 0, a: 1, b: 1}));
// Run the aggregate once where the $project can be pushed down.
// @tags: [
// sbe_incompatible,
// ]
const projectPushedDownRes =
coll.aggregate([{$sort: {a: 1}}, {$project: {_id: 0, metaField: {$meta: "sortKey"}}}])
.toArray();
// Run it again where it cannot be pushed down.
const projectNotPushedDownRes = coll.aggregate([
{$sort: {a: 1}},
{$unwind: {path: "$a"}},
{$project: {_id: 0, metaField: {$meta: "sortKey"}}}
])
.toArray();
assert.eq(projectPushedDownRes, projectNotPushedDownRes);
})();
|