[COMPASS-5492] $round and $dateSubtract not working in aggregation Created: 05/Feb/22  Updated: 03/Oct/23  Resolved: 26/Sep/22

Status: Closed
Project: Compass
Component/s: Aggregation pipeline, Compass
Affects Version/s: 1.30.1
Fix Version/s: No version

Type: Bug Priority: Major - P3
Reporter: Dan Lamprey Assignee: Unassigned
Resolution: Cannot Reproduce Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Attachments: PNG File MongoDB Compass Issue.png    
Issue Links:
Backports
backported by COMPASS-3977 $round operator not supported in aggr... Closed
Documentation Changes: Not Needed
UserVoice Links:

Issue with $round previously reported and fixed? $dateSubtract new issue?

I am new to MongoDB and this issue cost me hours of time as I thought it was a mistake on my part. Hoping you can fix it as I like creating aggregates in Compass, but will now have to use VS Code.


 Description   

Using $round and $dateSubtract do not work when creating an aggregation in Compass. when using those functions, the font does not turn blue or pass validation to allow execution. Since it would not pass validation, valid syntax would not execution, though I was able to execute it using it in VS Code.



 Comments   
Comment by Rhys Howell [ 26/Sep/22 ]

Unable to reproduce in Compass 1.33.1
Feel free to reopen if more information comes up.

Comment by Maurizio Casimirri [ 10/Jun/22 ]

offhomz@gmail.com Thanks for reporting this issue. Compass does not validate stage operators, it only validates the structure of the JSON. Can you provide the pipeline you are trying to run in a textual form so we can try to reproduce it on our own? It would be super helpful for us. Thanks!

I could run the following pipelines from our docs without issues:

[
   { $project: { roundedValue: { $round: [ "$value", 0 ] } } }
]

[
      {
         $match:
            {
               $expr:
                  {
                     $gt:
                        [
                           "$logoutTime",
                            {
                               $dateSubtract:
                                  {
                                     startDate: "$$NOW",
                                     unit: "week",
                                     amount: 1
                                  }
                            }
                        ]
                  }
             }
      },
      {
         $project:
            {
               _id: 0,
               custId: 1,
               loggedOut:
                  {
                     $dateToString:
                        {
                           format: "%Y-%m-%d",
                           date: "$logoutTime"
                        }
                  }
            }
      }
   ]

Generated at Wed Feb 07 22:39:45 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.