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

SBE and Classic behave differently for $bitsAnyClear on NumberDecimal infinity

    • Query Execution
    • Fully Compatible
    • v7.3, v7.0, v6.0, v5.0
    • QE 2024-02-19, QE 2024-03-04, QE 2024-03-18
    • 41

      Minimal example:

      (function() {
          db.c.insert({_id: 1, num: NumberDecimal("infinity")});
          const pipe = [{$match: {"num": {$bitsAnyClear: 11111000}}}];
          let explain = db.c.explain().aggregate(pipe);
          if (explain.queryPlanner.winningPlan.slotBasedPlan) {
              print("EXPLAIN: \n" + explain.queryPlanner.winningPlan.slotBasedPlan.stages);
          print("RESULTS: " + tojson(db.c.aggregate(pipe).toArray()));

      This pipeline gives different results between SBE and classic. Classic returns the document, while SBE does not. According to our documentation, $bitsAnyClear will not match values which can't be represented in a 64 bit integer (See "floating point" section of the page). SBE's behavior matches the documentation (hence I'm not marking this as a "bug" ticket).

      There is a note in some of the SBE stage builder code that we try to match classic's behavior despite the documentation (see here).

            kristina.znam@mongodb.com Kristina Znam
            ian.boros@mongodb.com Ian Boros
            0 Vote for this issue
            6 Start watching this issue