Details
Description
If a projection computes `obj` only in terms of a meta field and another field `blergh` is computed in terms of value of `obj` IN THE SAME PROJECTION, then we will push down the meta-field-only computation of `obj`. This causes `obj` to be overwritten before we can compute `blergh` causing an incorrect calculation.
See the example below where `obj` is `obj` and `blergh` is `b`.
db.c.drop()
|
db.d.drop()
|
db.createCollection("c", {timeseries: {timeField: "t", metaField: "m"}}) |
db.c.insert({obj: {a: 3}, m: {}, t: new Date()}) |
db.d.insert({obj: {a: 3}, m: {}, t: new Date()}) |
|
|
db.d.aggregate([{$addFields: {obj: "$m", b: {$add: ["$obj.a", 1]}}}]) |
// Correct result { "_id" : ObjectId("6285641318f6a25daf333976"), "obj" : { }, "m" : { }, "t" : ISODate("2022-05-18T21:24:35.843Z"), "b" : 4 }
|
|
|
db.c.aggregate([{$addFields: {obj: "$m", b: {$add: ["$obj.a", 1]}}}]) |
// incorrect result { "t" : ISODate("2022-05-18T21:24:57.873Z"), "m" : { }, "_id" : ObjectId("6285642918f6a25daf333978"), "obj" : { }, "b" : null } |
Attachments
Issue Links
- is related to
-
SERVER-64102 $project field that references time-series meta field can be referenced by second $project field
-
- Closed
-
-
SERVER-70940 Use internal names during stage reordering to prevent ambiguity
-
- Closed
-