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

cellFoldValues_F receives input that is neither Boolean nor Nothing

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 8.0.0-rc0
    • Affects Version/s: None
    • Component/s: None
    • Labels:
      None
    • Query Execution
    • Fully Compatible
    • ALL
    • Hide
      db.createCollection( "coll", { timeseries: { timeField: "time" } })
      
      db.coll.insertOne({
      _id: 0, 
      time: new Date("2023-09-02T22:56:01.615Z"), 
      measurement: -689.713747639426
      })
      
      db.coll.aggregate([{ $match: { $expr: { $trunc: "$measurement" } } }, { $count: "num" }])
      

      SBE plan

      [4] project [s12 = makeBsonObj(MakeObjSpec([num], [num], Closed, RetNothing), null, true, s11)]
      [3] project [s11 =
          if isNumber(s10)
          then s10
          else doubleDoubleSumFinalize(s10)
      ]
      [3] group [s7] [s10 = sum(1)] spillSlots[s9] mergingExprs[convertSimpleSumToDoubleDoubleSum(s9)]
      [3] block_to_row blocks[s3] row[s8] s5
      [3] project [s7 = null]
      [2] filter {!(valueBlockNone(s5, true))}
      [2] project [s5 = valueBlockFillEmpty(valueBlockCoerceToBool(
          let [
              l101.0 = cellFoldValues_F(valueBlockFillEmpty(valueBlockTypeMatch(cellBlockGetFlatValuesBlock(s3), 1088), true), s3)
          ]
          in valueBlockCombine(valueBlockNewFill(null, valueBlockSize(l101.0)),
              let [
                  l102.0 = cellFoldValues_F(valueBlockTypeMatch(cellBlockGetFlatValuesBlock(s3), 851970), s3)
              ]
              in valueBlockCombine(cellFoldValues_F(valueBlockTrunc(cellBlockGetFlatValuesBlock(s3), 0), s3),
                  let [
                      l103.0 = valueBlockLogicalNot(l102.0)
                  ]
                  in valueBlockNewFill(
                      if valueBlockNone(valueBlockLogicalAnd(valueBlockLogicalNot(l101.0), l103.0), true)
                      then Nothing
                      else fail(5155300, "$trunc only supports numeric types")
                 , valueBlockSize(l103.0))
             , l102.0)
         , l101.0)
      ), false)]
      [2] ts_bucket_to_cellblock s1 pathReqs[s3 = ProjectPath(Get(measurement)/Id), s4 = FilterPath(Get(measurement)/Traverse/Id)]
      [1] scan s1 s2 none none none none none none lowPriority [] @"29637d73-69c8-48a0-a962-47f3c6deff62" true false
      
      Show
      db.createCollection( "coll" , { timeseries: { timeField: "time" } }) db.coll.insertOne({ _id: 0, time: new Date( "2023-09-02T22:56:01.615Z" ), measurement: -689.713747639426 }) db.coll.aggregate([{ $match: { $expr: { $trunc: "$measurement" } } }, { $count: "num" }]) SBE plan [4] project [s12 = makeBsonObj(MakeObjSpec([num], [num], Closed, RetNothing), null , true , s11)] [3] project [s11 = if isNumber(s10) then s10 else doubleDoubleSumFinalize(s10) ] [3] group [s7] [s10 = sum(1)] spillSlots[s9] mergingExprs[convertSimpleSumToDoubleDoubleSum(s9)] [3] block_to_row blocks[s3] row[s8] s5 [3] project [s7 = null ] [2] filter {!(valueBlockNone(s5, true ))} [2] project [s5 = valueBlockFillEmpty(valueBlockCoerceToBool( let [ l101.0 = cellFoldValues_F(valueBlockFillEmpty(valueBlockTypeMatch(cellBlockGetFlatValuesBlock(s3), 1088), true ), s3) ] in valueBlockCombine(valueBlockNewFill( null , valueBlockSize(l101.0)), let [ l102.0 = cellFoldValues_F(valueBlockTypeMatch(cellBlockGetFlatValuesBlock(s3), 851970), s3) ] in valueBlockCombine(cellFoldValues_F(valueBlockTrunc(cellBlockGetFlatValuesBlock(s3), 0), s3), let [ l103.0 = valueBlockLogicalNot(l102.0) ] in valueBlockNewFill( if valueBlockNone(valueBlockLogicalAnd(valueBlockLogicalNot(l101.0), l103.0), true ) then Nothing else fail(5155300, "$trunc only supports numeric types" ) , valueBlockSize(l103.0)) , l102.0) , l101.0) ), false )] [2] ts_bucket_to_cellblock s1 pathReqs[s3 = ProjectPath(Get(measurement)/Id), s4 = FilterPath(Get(measurement)/Traverse/Id)] [1] scan s1 s2 none none none none none none lowPriority [] @ "29637d73-69c8-48a0-a962-47f3c6deff62" true false
    • QE 2024-03-18, QE 2024-04-01
    • 152

      cellFoldValues_F assumes that the input block will have only boolean values or Nothing. However, it is possible to call cellFoldValues_F with values of other type.

      We should add a CoerceToBool before we call cellFoldValues_F to make sure that we get the correct results.

      After discussion with alberto.massari@mongodb.com adding CoerceToBool by default will result in producing wrong results. cellFoldValues_F should produce the same results as traverseF which returns true for an array by ORing the results of each array element. The result of each array element is computed applying a lambda function on it. When the function returns a boolean true value the results for the array element is true. In all other cases the result of the array element is false.

            Assignee:
            foteini.alvanaki@mongodb.com Foteini Alvanaki
            Reporter:
            foteini.alvanaki@mongodb.com Foteini Alvanaki
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: