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

$fill can't take a single field in "partitionBy"

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Minor - P4 Minor - P4
    • 6.0.1
    • Affects Version/s: 5.3.0
    • Component/s: None
    • Fully Compatible
    • ALL
    • Hide

      Example:

      Input:

      db.coffee.insertMany( [ 
            {
               "altitude": 600,
               "variety": "Arabica Typica",
               "health": 68.3
            },
            {
               "altitude": 600,
               "variety": "Gesha",
               "health": 90.2
            },
            {
               "altitude": 700,
               "variety": "Arabica Typica",
               "health": 69.5
            },
            {
               "altitude": 700,
               "variety": "Gesha"
            },
            {
               "altitude": 800,
               "variety": "Arabica Typica"
            },
            {
               "altitude": 800,
               "variety": "Gesha",
               "health": 86.9
            },
            {
              "altitude": 900,
              "variety": "Arabica Typica",
              "health": 72.5
            },
            {
               "altitude": 900,
               "variety": "Gesha"
            },
            {
               "altitude": 1000,
               "variety": "Arabica Typica",
               "health": 73.0
            },
            {
               "altitude": 1000,
               "variety": "Gesha",
               "health": 80.4
            },
         ] )
      

      Aggregation:

      db.coffee.aggregate([
            {
               $fill:
                  {
                     sortBy: { altitude: 1 },
                     partitionBy: "$variety",
                     output:
                        {
                           "health": { method: "linear" }
                        }
                  }
            }
         ])
      

      Errors with this output:

      BSON field '$fill.partitionBy' is the wrong type 'string', expected type 'object'
      

      The expectation is that this aggregation would successfully partition the data by the two coffee varieties.

      Show
      Example: Input: db.coffee.insertMany( [ { "altitude" : 600, "variety" : "Arabica Typica" , "health" : 68.3 }, { "altitude" : 600, "variety" : "Gesha" , "health" : 90.2 }, { "altitude" : 700, "variety" : "Arabica Typica" , "health" : 69.5 }, { "altitude" : 700, "variety" : "Gesha" }, { "altitude" : 800, "variety" : "Arabica Typica" }, { "altitude" : 800, "variety" : "Gesha" , "health" : 86.9 }, { "altitude" : 900, "variety" : "Arabica Typica" , "health" : 72.5 }, { "altitude" : 900, "variety" : "Gesha" }, { "altitude" : 1000, "variety" : "Arabica Typica" , "health" : 73.0 }, { "altitude" : 1000, "variety" : "Gesha" , "health" : 80.4 }, ] ) Aggregation: db.coffee.aggregate([ { $fill: { sortBy: { altitude: 1 }, partitionBy: "$variety" , output: { "health" : { method: "linear" } } } } ]) Errors with this output: BSON field '$fill.partitionBy' is the wrong type 'string' , expected type 'object' The expectation is that this aggregation would successfully partition the data by the two coffee varieties.

      $fill fails when a user tries to specify a single field in "partitionBy" without wrapping it in an object. This is at odds with the syntax supported by the "partitionBy" field for $setWindowFields, where users can specify a single field name.

            Assignee:
            maddie.zechar@mongodb.com Maddie Zechar
            Reporter:
            jeffrey.allen@mongodb.com Jeffrey Allen
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: