[SERVER-67284] $fill.partitionByFields does not allow the dot notation for embedded documents Created: 14/Jun/22  Updated: 29/Oct/23  Resolved: 28/Jul/22

Status: Closed
Project: Core Server
Component/s: None
Affects Version/s: 5.3.1
Fix Version/s: 6.1.0-rc0

Type: Bug Priority: Major - P3
Reporter: Valentin Kavalenka Assignee: Ted Tuckman
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Attachments: PNG File Screen Shot 2022-06-14 at 14.56.12.png    
Issue Links:
Documented
is documented by DOCS-15510 Investigate changes in SERVER-67284: ... Backlog
Backwards Compatibility: Fully Compatible
Operating System: ALL
Participants:

 Description   

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:


Generated at Thu Feb 08 06:07:44 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.