[COMPASS-3977] $round operator not supported in aggregation pipeline builder Created: 26/Nov/19  Updated: 29/Oct/23  Resolved: 17/Mar/20

Status: Closed
Project: Compass
Component/s: Aggregation pipeline, Grammar
Affects Version/s: 1.19.12
Fix Version/s: 1.22.0

Type: Bug Priority: Major - P3
Reporter: Ilian Gagliardi Assignee: Unassigned
Resolution: Fixed Votes: 1
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

MacOs Catalina 10.15.1


Issue Links:
Backports
backports COMPASS-5492 $round and $dateSubtract not working ... Closed
Duplicate
is duplicated by COMPASS-3980 $round not working in aggregation Closed
Problem/Incident
causes COMPASS-4146 Disable validation in agg builder, qu... Closed
Epic Link: COMPASS-3417

 Description   

using mongoDB 4.2.1 and Compass 1.19.12,  I noticed that the $round operator is not working with the aggregation pipeline builder. same . I tried also Compass 1.20 beta 9, same result.

sample document:

 {{{
"_id" : ObjectId("5ddbe2272d639f32f2f8cb00"),
"bucket" : ISODate("2019-11-25T14:16:00Z"),
"measure" : "SE03_a_RMS_Freq_01",
"path" : "TL1/Z01/HCZ01/KAV01",
"count" : 3,
"sum" : 77,
"raw" : [

{ "ts" : ISODate("2019-11-25T14:16:07.880Z"), "v" : 15, "program" : "01", "programBT" : ISODate("2019-11-25T14:16:00Z") }

,

{ "ts" : ISODate("2019-11-25T14:16:07.883Z"), "v" : 23, "program" : "01", "programBT" : ISODate("2019-11-25T14:16:00Z") }

,

{ "ts" : ISODate("2019-11-25T14:16:07.885Z"), "v" : 39, "program" : "01", "programBT" : ISODate("2019-11-25T14:16:00Z") }

]
}}}

example aggregation pipeline (working with mongoshell):
{{ [{$match: {
bucket:

{ $gte: ISODate('2019-11-23T19:11:00.000Z') }

,
measure: RegExp('^SE01')
}}, {$sort: {
bucket: -1
}}, {$unwind: {
path: '$raw'
}}, {$group: {
_id:

{ bucket: '$bucket', measure: '$measure' }

,
avg:

{ $avg : '$raw.v' }

,
min:

{ $min: '$raw.v' }

,
max:

{ $max: '$raw.v' }

}}, {$project: {
val : {$round : ['$avg',2]}
}}]}}
 

error on compass, last projection stage:
Expected "[" or AggregationStage but "{" found.


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