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

Make ExpressionSetUnion::isCommutative() collation aware

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 4.2.23, 4.4.17, 6.0.1, 5.0.11, 6.1.0-rc0
    • Affects Version/s: 4.4.13, 5.0.7, 4.2.20, 6.0.0-rc5, 6.1.0-rc0
    • Component/s: None
    • Labels:
      None
    • Fully Compatible
    • ALL
    • v6.0, v5.0, v4.4, v4.2
    • Hide

      To reproduce run the following:

      db.coll.drop();
      var coll = db.coll;
       
      coll.insertOne({_id: 0, time: new Date("2019-10-18T18:40:14.299Z") });
       
      const pl = [ {$group: {_id: {$setUnion: [["\u0019"], [{$reduce: {input: ["xyz"], initialValue: "aaa", in: ""}}], [[{}]]]}}} ];
      const collation = {locale: 'en_US', strength: 2, }
      
      db.adminCommand({'configureFailPoint': 'disablePipelineOptimization', 'mode': 'off'});
       
      db.runCommand({aggregate: "coll", pipeline: pl, cursor: {}, collation: collation});
      db.runCommand({aggregate: "coll", pipeline: pl, cursor: {}, collation: collation, explain: true});
       
      db.adminCommand({'configureFailPoint': 'disablePipelineOptimization', 'mode': 'alwaysOn'});
      db.runCommand({aggregate: "coll", pipeline: pl, cursor: {}, collation: collation});
      db.runCommand({aggregate: "coll", pipeline: pl, cursor: {}, collation: collation, explain: true});
      
      Show
      To reproduce run the following: db.coll.drop(); var coll = db.coll; coll.insertOne({_id: 0, time: new Date( "2019-10-18T18:40:14.299Z" ) }); const pl = [ {$group: {_id: {$setUnion: [[ "\u0019" ], [{$reduce: {input: [ "xyz" ], initialValue: "aaa" , in: ""}}], [[{}]]]}}} ]; const collation = {locale: 'en_US' , strength: 2, } db.adminCommand({ 'configureFailPoint' : 'disablePipelineOptimization' , 'mode' : 'off' }); db.runCommand({aggregate: "coll" , pipeline: pl, cursor: {}, collation: collation}); db.runCommand({aggregate: "coll" , pipeline: pl, cursor: {}, collation: collation, explain: true }); db.adminCommand({ 'configureFailPoint' : 'disablePipelineOptimization' , 'mode' : 'alwaysOn' }); db.runCommand({aggregate: "coll" , pipeline: pl, cursor: {}, collation: collation}); db.runCommand({aggregate: "coll" , pipeline: pl, cursor: {}, collation: collation, explain: true });
    • QO 2022-05-16, QO 2022-05-30
    • 18

      The $setUnion aggregation expression is currently defined to be always commutative. This breaks down a collation is in place that can compare 2 different binary values as being the same. We should consider making ExpressionSetUnion::isCommutative() return false when a non-simple collation is in place.

            Assignee:
            james.wahlin@mongodb.com James Wahlin
            Reporter:
            timour.katchaounov@mongodb.com Timour Katchaounov
            Votes:
            0 Vote for this issue
            Watchers:
            9 Start watching this issue

              Created:
              Updated:
              Resolved: