diff options
author | Ivan Fefer <ivan.fefer@mongodb.com> | 2022-10-20 07:42:58 +0000 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2022-10-20 08:38:46 +0000 |
commit | 9c348fbfafacc93b06d8d4c5521925c97150089f (patch) | |
tree | b2aa2b1bc00d6d24d8a136b3af307e1789f26b4d /jstests/aggregation | |
parent | 28450cf43e1c28c2bf6b75c9fdfec6ad96ad584b (diff) | |
download | mongo-9c348fbfafacc93b06d8d4c5521925c97150089f.tar.gz |
SERVER-61284: Support simple projection optimization for simple exclusion projections
Diffstat (limited to 'jstests/aggregation')
-rw-r--r-- | jstests/aggregation/bugs/exclusion_projection_does_not_affect_field_order.js | 13 | ||||
-rw-r--r-- | jstests/aggregation/optimize_away_pipeline.js | 8 |
2 files changed, 12 insertions, 9 deletions
diff --git a/jstests/aggregation/bugs/exclusion_projection_does_not_affect_field_order.js b/jstests/aggregation/bugs/exclusion_projection_does_not_affect_field_order.js index 4bc45bccef5..09d2239389a 100644 --- a/jstests/aggregation/bugs/exclusion_projection_does_not_affect_field_order.js +++ b/jstests/aggregation/bugs/exclusion_projection_does_not_affect_field_order.js @@ -2,6 +2,10 @@ // changes. // // This is designed as a regression test for SERVER-37791. +// @tags: [ +// do_not_wrap_aggregations_in_facets, +// requires_fcv_62, +// ] (function() { "use strict"; @@ -13,13 +17,14 @@ assert.commandWorked(coll.insert({_id: 2, c: 1})); assert.commandWorked(coll.insert({_id: 3, y: 1, z: 1})); // We expect $addFields to retain the position of pre-existing fields, and then append new fields in -// the order that they are specified in the query. This rule should not be impacted by the presence -// of a preceding exclusion projection. +// the order that they are specified in the query. This rule should not be impacted by exclusion +// projection on non-existent fields. However, depending on projection implementation, excluding a +// field that already exists can affect $addFields behaviour: an excluded field can be put in +// the original place or appended to the end of the document. assert.eq( [ {_id: 1, x: 3, y: 4, b: 5, c: 6, a: 7}, - // Here "c" retains the position that it had prior to being excluded. - {_id: 2, c: 6, x: 3, y: 4, b: 5, a: 7}, + {_id: 2, x: 3, y: 4, b: 5, c: 6, a: 7}, {_id: 3, y: 4, z: 1, x: 3, b: 5, c: 6, a: 7} ], coll.aggregate([ diff --git a/jstests/aggregation/optimize_away_pipeline.js b/jstests/aggregation/optimize_away_pipeline.js index 36921f42c34..d08bde70f5d 100644 --- a/jstests/aggregation/optimize_away_pipeline.js +++ b/jstests/aggregation/optimize_away_pipeline.js @@ -690,13 +690,11 @@ projStage = getAggPlanStage(explain, "PROJECTION_SIMPLE"); assert.neq(null, projStage, explain); assertTransformByShape({a: 1, b: 1, _id: 0}, projStage.transformBy, explain); -// Test that an exclusion projection at the front of the pipeline is not pushed down, if there no +// Test that an exclusion projection at the front of the pipeline is pushed down if there is no // finite dependency set. pipeline = [{$project: {x: 0}}]; -assertPipelineUsesAggregation({pipeline: pipeline, expectedStages: ["COLLSCAN"]}); -explain = coll.explain().aggregate(pipeline); -assert(!planHasStage(db, explain, "PROJECTION_SIMPLE"), explain); -assert(!planHasStage(db, explain, "PROJECTION_DEFAULT"), explain); +assertPipelineDoesNotUseAggregation( + {pipeline: pipeline, expectedStages: ["PROJECTION_SIMPLE", "COLLSCAN"]}); // Test that a computed projection at the front of the pipeline is pushed down, even if there's no // finite dependency set. |