Uploaded image for project: 'Compass '
  1. Compass
  2. COMPASS-3977

$round operator not supported in aggregation pipeline builder

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 1.22.0
    • Affects Version/s: 1.19.12
    • None
    • Environment:
      MacOs Catalina 10.15.1

      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.

            Assignee:
            Unassigned Unassigned
            Reporter:
            ilian.gagliardi@mongodb.com Ilian Gagliardi
            Votes:
            1 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: