-
Type: Bug
-
Resolution: Done
-
Priority: Major - P3
-
None
-
Affects Version/s: None
-
Component/s: Aggregation Framework
-
None
-
Environment:Using mongodb-org-6.0.0-0.1.latest.el7.x86_64 on CentOS 7
-
ALL
The $densify aggregation pipeline stage seems unable to evaluate range bounds expressions, requiring the range bounds to be constant.
See the following example (the collection testcoll contains a single documents with only the _id field):
sometestdb> db.testcoll.aggregate([{$addFields: {a: 1}}, {$densify: {field: "a", range: {bounds: [0, 5], step: 1}}}]) [ { a: 0 }, { _id: ObjectId("6284a16d64553eaf74b1e189"), a: 1 }, { a: 2 }, { a: 3 }, { a: 4 } ] sometestdb> db.testcoll.aggregate([{$addFields: {a: 1}}, {$densify: {field: "a", range: {bounds: [{$toInt: "0"}, 5], step: 1}}}]) MongoServerError: A bounding array must be an ascending array of either two dates or two numbers
The first aggregate() call gives the correct result, and I'd expect the second one to evaluate the $toInt and yield the same result. Of course $toInt isn't a particularly useful use case but there are indeed useful computations which an user may want to do on the range bounds; for example, when using dates, one may want to truncate the start and end date to the hour or to the day before they are used for the densify operation.
- related to
-
SERVER-68108 $densify with dynamic bounds array causes "A bounding array must contain either both dates or both numeric types" error
- Closed