-
Type: Bug
-
Resolution: Fixed
-
Priority: Major - P3
-
Affects Version/s: None
-
Component/s: None
-
Query Execution
-
Fully Compatible
-
ALL
-
v8.0, v7.3, v7.0
-
QE 2024-05-27, QE 2024-06-10, QE 2024-06-24
-
0
The following pipeline returns different results with optimisations disabled via the "disablePipelineOptimization" failpoint:
// Collection contains only the document: {outer: [{inner: 0}]} [ { $project: { flattened: { $map: {input: '$outer', as: "iter", in : "$$iter.inner"}, }, }, }, { $match: {flattened: {$elemMatch: {$eq: 0}}, } ];
- With the optimisation it returns []
- Without the optimisation it returns [{flattened: [0]}]
The rewrite turns the match expression into {$match: {"outer.inner": {$elemMatch: {$eq: 0}}}} which is not exactly the same in this context due to implicit dotted array traversal. [Mongo docs.
- is related to
-
SERVER-91197 Allow $elemMatch expressions to be swapped before $map projections
- Open
- related to
-
SERVER-73914 Implement renames for kArrayMatching MatchExpressions
- Closed