Timeseries predicate pushdown drops NaN-containing bucket

    • Type: Bug
    • Resolution: Unresolved
    • Priority: Major - P3
    • None
    • Affects Version/s: None
    • Component/s: None
    • Query Integration
    • ALL
    • Hide
      const conn = MongoRunner.runMongod();
      const testDB = conn.getDB(jsTestName());
      const tsColl = testDB.ts_nan_min_repro;
      const regularColl = testDB.regular_nan_min_repro;
      
      assert.commandWorked(
          testDB.createCollection(tsColl.getName(), {timeseries: {timeField: "ts", metaField: "m"}}));
      
      const docs = [
          {ts: ISODate("2024-01-01T00:00:00Z"), m: 1, v: 1},
          {ts: ISODate("2024-01-01T00:01:00Z"), m: 1, v: NaN},
          {ts: ISODate("2024-01-01T00:02:00Z"), m: 1, v: 100},
      ];
      assert.commandWorked(tsColl.insertMany(docs));
      assert.commandWorked(regularColl.insertMany(docs));
      
      const pipeline = [{$match: {v: {$lt: 50}}}, {$project: {_id: 0, v: 1}}];
      const expected = regularColl.aggregate(pipeline).toArray();
      const actual = tsColl.aggregate(pipeline).toArray();
      
      // Expected: [{v: 1}] <-> Actual: []
      assert.eq(expected, actual, "Time-series results should match a regular collection");MongoRunner.stopMongod(conn); 
      Show
      const conn = MongoRunner.runMongod(); const testDB = conn.getDB(jsTestName()); const tsColl = testDB.ts_nan_min_repro; const regularColl = testDB.regular_nan_min_repro; assert .commandWorked(     testDB.createCollection(tsColl.getName(), {timeseries: {timeField: "ts" , metaField: "m" }})); const docs = [     {ts: ISODate( "2024-01-01T00:00:00Z" ), m: 1, v: 1},     {ts: ISODate( "2024-01-01T00:01:00Z" ), m: 1, v: NaN},     {ts: ISODate( "2024-01-01T00:02:00Z" ), m: 1, v: 100}, ]; assert .commandWorked(tsColl.insertMany(docs)); assert .commandWorked(regularColl.insertMany(docs)); const pipeline = [{$match: {v: {$lt: 50}}}, {$project: {_id: 0, v: 1}}]; const expected = regularColl.aggregate(pipeline).toArray(); const actual = tsColl.aggregate(pipeline).toArray(); // Expected: [{v: 1}] <-> Actual: [] assert .eq(expected, actual, "Time-series results should match a regular collection" );MongoRunner.stopMongod(conn);
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      Problem

      A timeseries aggregation can return incorrect results when a measurement field contains NaN and the pipeline has a $match on that field followed by an inclusion $project. A regular collection with the same documents returns the expected matching measurement, but the time-series collection returns an empty result.

      Reproduction

      Insert three measurements into a time-series collection:

      {ts: ISODate("2024-01-01T00:00:00Z"), m: 1, v: 1}
      {ts: ISODate("2024-01-01T00:01:00Z"), m: 1, v: NaN}
      {ts: ISODate("2024-01-01T00:02:00Z"), m: 1, v: 100}
      

      Run:

      [{$match: {v: {$lt: 50}}}, {$project: {_id: 0, v: 1}}]
      

      Expected result, matching regular collection behavior:

      [{v: 1}]
      

      Actual time-series result:

      []
      

            Assignee:
            Unassigned
            Reporter:
            Max Verbinnen
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: