diff options
author | Svilen Mihaylov <svilen.mihaylov@mongodb.com> | 2022-05-18 19:10:49 +0000 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2022-05-18 20:01:46 +0000 |
commit | 493567c3a2f4ae6ecc025608f3282cc405c5fd7c (patch) | |
tree | 288e9f3f79de23127d8f690422739f6e5de34013 /jstests/cqf | |
parent | 0fdf27b6bb98760750ba41b0c246e04d395f3f2b (diff) | |
download | mongo-493567c3a2f4ae6ecc025608f3282cc405c5fd7c.tar.gz |
SERVER-66547 Implement simple agg comparison for new optimizer
Diffstat (limited to 'jstests/cqf')
-rw-r--r-- | jstests/cqf/match_expr.js | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/jstests/cqf/match_expr.js b/jstests/cqf/match_expr.js new file mode 100644 index 00000000000..a02cfbffde0 --- /dev/null +++ b/jstests/cqf/match_expr.js @@ -0,0 +1,39 @@ +(function() { +"use strict"; + +load("jstests/libs/optimizer_utils.js"); // For checkCascadesOptimizerEnabled. +if (!checkCascadesOptimizerEnabled(db)) { + jsTestLog("Skipping test because the optimizer is not enabled"); + return; +} + +const t = db.cqf_match_expr; +t.drop(); + +const bulk = t.initializeUnorderedBulkOp(); +for (let va = 0; va < 5; va++) { + for (let vb = 0; vb < 5; vb++) { + for (let vc = 0; vc < 5; vc++) { + bulk.insert({a: va, b: vb, c: vc}); + } + } +} +assert.commandWorked(bulk.execute()); + +{ + const res = t.explain("executionStats").aggregate([{ + $match: { + $expr: { + $or: [ + {$and: [{$eq: ["$a", 1]}, {$eq: ["$b", 2]}]}, + {$eq: ["$c", 3]}, + ] + } + } + }]); + + assert.eq(1 * 5 * 5 + 4 * 1 * 1, res.executionStats.nReturned); + + // TODO: verify translated plan. +} +}()); |