[SERVER-63503] $fill can't take a single field in "partitionBy" Created: 09/Feb/22  Updated: 29/Oct/23  Resolved: 29/Aug/22

Status: Closed
Project: Core Server
Component/s: None
Affects Version/s: 5.3.0
Fix Version/s: 6.0.1

Type: Bug Priority: Minor - P4
Reporter: Jeffrey Allen Assignee: Maddie Zechar
Resolution: Fixed Votes: 0
Labels: neweng
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Backwards Compatibility: Fully Compatible
Operating System: ALL
Steps To Reproduce:

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.

Participants:

 Description   

$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.



 Comments   
Comment by Githook User [ 30/Jun/22 ]

Author:

{'name': 'Zahra Poonevala', 'email': 'zahra.poonevala@mongodb.com', 'username': 'zahrapoonevala123'}

Message: SERVER-63503 $fill.partitionBy accepts string or object
Branch: master
https://github.com/mongodb/mongo/commit/07b59b69e23e511a63da70a25e88fc87e206ce3a

Generated at Thu Feb 08 05:57:56 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.