Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-63425

$setUnion convert NumberDecimal to NumberLong when pipeline optimization is turned off

    • Type: Icon: Bug Bug
    • Resolution: Won't Fix
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: Aggregation Framework
    • None
    • ALL
    • QO 2022-02-21
    • 40

      It is applicable for Classic Execution Engine only. Test to reproduce: see the attached file.

      const document = { "num": 29439 };
      assert.commandWorked(coll.insertOne(document));
      const pipeline = [{
          $bucketAuto: {
              groupBy: {$setUnion: [[NumberLong("0")], ["$num", NumberDecimal("-0")]]},
              buckets: NumberInt(18)
          }
      }];
      
      [js_test:bf24145] uncaught exception: Error: [[
      [js_test:bf24145]       {
      [js_test:bf24145]               "_id" : {
      [js_test:bf24145]                       "min" : [
      [js_test:bf24145]                               NumberDecimal("-0"),
      [js_test:bf24145]                               29439
      [js_test:bf24145]                       ],
      [js_test:bf24145]                       "max" : [
      [js_test:bf24145]                               NumberDecimal("-0"),
      [js_test:bf24145]                               29439
      [js_test:bf24145]                       ]
      [js_test:bf24145]               },
      [js_test:bf24145]               "count" : 1
      [js_test:bf24145]       }
      [js_test:bf24145] ]] != [[
      [js_test:bf24145]       {
      [js_test:bf24145]               "_id" : {
      [js_test:bf24145]                       "min" : [
      [js_test:bf24145]                               NumberLong(0),
      [js_test:bf24145]                               29439
      [js_test:bf24145]                       ],
      [js_test:bf24145]                       "max" : [
      [js_test:bf24145]                               NumberLong(0),
      [js_test:bf24145]                               29439
      [js_test:bf24145]                       ]
      [js_test:bf24145]               },
      [js_test:bf24145]               "count" : 1
      [js_test:bf24145]       }
      [js_test:bf24145] ]] are not equal :
      [js_test:bf24145] doassert@src/mongo/shell/assert.js:20:14
      [js_test:bf24145] assert.docEq@src/mongo/shell/assert.js:205:9
      [js_test:bf24145] @jstests/bf24145.js:31:1
      [js_test:bf24145] @jstests/bf24145.js:1:2

        1. bf-24145.js
          0.9 kB
          Alexander Ignatyev

            Assignee:
            alexander.ignatyev@mongodb.com Alexander Ignatyev
            Reporter:
            alexander.ignatyev@mongodb.com Alexander Ignatyev
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: