[SERVER-66536] Support expressions in $densify range bounds Created: 18/May/22  Updated: 21/Jul/22  Resolved: 23/May/22

Status: Closed
Project: Core Server
Component/s: Aggregation Framework
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Major - P3
Reporter: Gianluca Nitti Assignee: Unassigned
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Using mongodb-org-6.0.0-0.1.latest.el7.x86_64 on CentOS 7


Issue Links:
Related
related to SERVER-68108 $densify with dynamic bounds array ca... Closed
Operating System: ALL
Participants:

 Description   

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.



 Comments   
Comment by Chris Kelly [ 23/May/22 ]

Hi Gianluca,

Can I please ask that you submit this as a request at feedback.mongodb.com? We're starting to direct new feature requests and improvements to that channel and preferring this JIRA project for bug reports specifically.

Christopher

Generated at Thu Feb 08 06:05:43 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.