diff options
Diffstat (limited to 'jstests/aggregation/sources')
-rw-r--r-- | jstests/aggregation/sources/bucketauto/granularity_near_zero.js | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/jstests/aggregation/sources/bucketauto/granularity_near_zero.js b/jstests/aggregation/sources/bucketauto/granularity_near_zero.js new file mode 100644 index 00000000000..7f456f9428d --- /dev/null +++ b/jstests/aggregation/sources/bucketauto/granularity_near_zero.js @@ -0,0 +1,22 @@ +// Tests when the granularity rounder needs to approach zero to round correctly. This test was +// designed to reproduce SERVER-57091. +(function() { +"use strict"; +const coll = db.server57091; +coll.drop(); +coll.insertOne({}); + +const res = + coll.aggregate([{ + $bucketAuto: { + groupBy: { + $reduce: + {input: [], initialValue: 4.940656484124654e-324, in : {$size: ["$$value"]}} + }, + buckets: NumberLong("8"), + granularity: "R80" + } + }]) + .toArray(); +assert.eq(res, [{_id: {min: 0, max: 1.02e-321}, count: 1}]); +})(); |