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

XMLWordPrintableJSON

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

      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
              Reporter:
              Valentin Kavalenka
              Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

                Created:
                Updated:
                Resolved: