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

$fill.partitionByFields does not allow the dot notation for embedded documents

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 6.1.0-rc0
    • Affects Version/s: 5.3.1
    • Component/s: None
    • None
    • Fully Compatible
    • ALL

      The following experiment run in mongosh against MongoDB 5.3.1

      use myDb
      db.myColl.drop()
      db.runCommand({"insert": "myColl", "documents": [
          {"_id": 1, "partition": {"id": 10}, "field": 1},
          {"_id": 2, "partition": {"id": 10}},
          {"_id": 3, "partition": {"id": 20}, "field": 3}] })
      db.runCommand({"aggregate": "myColl", "pipeline": [
          {"$fill": {
              "output": {
                  "field": {"method": "locf"}
              },
              "sortBy": {"_id": -1},
              "partitionByFields": ["partition.id"] }},
          {"$sort": {"_id": 1}},
          {"$project": {"field": true, "_id": false} }],
          "cursor": {} })
      

      results in

      MongoServerError: FieldPath field names may not contain '.'. Consider using $getField or $setField.
      

      Replacing

      "partitionByFields": ["partition.id"]
      

      with

      "partitionBy": {"p": "$partition.id"}
      

      makes it work and produce

      [ { field: 1 }, { field: null }, { field: 3 } ]
      

      kateryna.kamenieva@mongodb.com confirmed that this is a bug and the dot notation for embedded documents was intended to be supported in $fill.partitionByFields similarly to how it is supported in $densify.partitionByFields:

            Assignee:
            ted.tuckman@mongodb.com Ted Tuckman
            Reporter:
            valentin.kovalenko@mongodb.com Valentin Kavalenka
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: