DocumentSourceInternalSetWindowFields doesn't have sort key metadata in bounded sorts

XMLWordPrintableJSON

    • Query Integration
    • Fully Compatible
    • ALL
    • v8.2, v8.0
    • Hide
      const tsColl = db.getCollection('timeseriescoll');
      tsColl.drop();
      db.createCollection(tsColl.getName(), {
          timeseries: {
              timeField: 'recordedAt',
              metaField: 'metadata'}});
      
      const documents = [
          {
              _id: ObjectId('67adfb90dff55739b72bf65b'),
              metadata: {
                  vessel_id: ObjectId('67adfb90dff55739b72bf65a'),
                  logConfig_id: ObjectId('67adfb90dff55739b72bf65b')
              },
              recordedAt: new Date(1737331200000), // Mon Jan 21 2025
          },
      ]
      
      assert.commandWorked(tsColl.insert(documents));
      const index = { "metadata.vessel_id": 1, "recordedAt": -1 };
      assert.commandWorked(tsColl.createIndex(index));
      const pipeline = [
          { $setWindowFields: { sortBy: { recordedAt: -1 }, output: { rank: { $documentNumber: {} } } } }, 
      ];
      
      const result = tsColl.aggregate(pipeline).toArray(); 
      Show
      const tsColl = db.getCollection( 'timeseriescoll' ); tsColl.drop(); db.createCollection(tsColl.getName(), { timeseries: { timeField: 'recordedAt' , metaField: 'metadata' }}); const documents = [ { _id: ObjectId( '67adfb90dff55739b72bf65b' ), metadata: { vessel_id: ObjectId( '67adfb90dff55739b72bf65a' ), logConfig_id: ObjectId( '67adfb90dff55739b72bf65b' ) }, recordedAt: new Date(1737331200000), // Mon Jan 21 2025 }, ] assert .commandWorked(tsColl.insert(documents)); const index = { "metadata.vessel_id" : 1, "recordedAt" : -1 }; assert .commandWorked(tsColl.createIndex(index)); const pipeline = [ { $setWindowFields: { sortBy: { recordedAt: -1 }, output: { rank: { $documentNumber: {} } } } }, ]; const result = tsColl.aggregate(pipeline).toArray();
    • None
    • 3
    • TBD
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      This triggers an assertion in some cases, such as WindowFunctionExecNonRemovableCommon, which does expect to have the metadata.

              Assignee:
              Mariano Shaar
              Reporter:
              Mariano Shaar
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

                Created:
                Updated:
                Resolved: