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

$project incorrectly pushed down on timeseries when $project uses $getField on a measurement field

    XMLWordPrintableJSON

Details

    • Query Integration
    • Fully Compatible
    • ALL
    • v7.2
    • Hide

      assert.commandWorked(db.createCollection(coll.getName(), {timeseries: {timeField: 'time', metaField: 'tag'}})); 
       
      assert.commandWorked(coll.insert({ _id:1, time: new Date("2022-12-25T00:25:56.333Z"), tag:2, obj:3})); 
       
      // run aggregation
      coll.aggregate([ {$project: {"array": {$map: {input: ["$tag"], in: {$getField: "obj"}}}}}]) 
       
      // aggregation returns [ { "_id" : 1, "array" : [ null ] } ] 
       
      // but the aggregation should return[[ { "_id" : 1, "array" : [ 3 ] } ]] 

      Show
      assert .commandWorked(db.createCollection(coll.getName(), {timeseries: {timeField: 'time' , metaField: 'tag' }}));   assert .commandWorked(coll.insert({ _id: 1 , time: new Date( "2022-12-25T00:25:56.333Z" ), tag: 2 , obj: 3 }));   // run aggregation coll.aggregate([ {$project: { "array" : {$map: {input: [ "$tag" ], in: {$getField: "obj" }}}}}])   // aggregation returns [ { "_id" : 1, "array" : [ null ] } ]   // but the aggregation should return[[ { "_id" : 1, "array" : [ 3 ] } ]]
    • QI 2023-11-13, QI 2023-11-27
    • 0

    Description

      $project, $addFields and $set that reference the metaField are pushed before the $_internalUnpackBucket stage. However, we are not accounting for the case that these stages could have expressions with subexpressions that are dependent on measurement fields. Below is a minimal repro from a fuzzer BF.

      Attachments

        Activity

          People

            gil.alon@mongodb.com Gil Alon
            gil.alon@mongodb.com Gil Alon
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: