-
Type:
Bug
-
Resolution: Fixed
-
Priority:
Major - P3
-
Affects Version/s: None
-
Component/s: Querying
-
Fully Compatible
-
ALL
-
v5.1
-
QO 2021-11-29
-
None
-
None
-
None
-
None
-
None
-
None
-
None
db.getSiblingDB("test").weather.insertMany( [ { "_id": 0, "metadata": { "sensorId": 5578, "type": "temperature" }, "timestamp": ISODate("2021-05-18T00:00:00.000Z"), "temp": 12 }, {"_id": 1, "metadata": { "sensorId": 5578, "type": "temperature" }, "timestamp": ISODate("2021-05-18T02:00:00.000Z"), "temp": 14 } ] ); db.getSiblingDB("test").weather.aggregate([ { $densify: { field: "timestamp", partitionByFields: ["metadata.sensorId"], range: { step: 1, unit: "hour", bounds: "full" } } } ]);
Output:
1) It was supposed to create just one new document, but there's an extra document in the end without partition filed.
2) In the created document partition field metadata: {sensorId: 5578} became "metadata.sensorId": 5578
[
{
"_id": 0,
"metadata": {
"sensorId": 5578,
"type": "temperature"
},
"timestamp": {
"$date": "2021-05-18T00:00:00Z"
},
"temp": 12
},
{
"metadata.sensorId": 5578,
"timestamp": {
"$date": "2021-05-18T01:00:00Z"
}
},
{
"_id": 1,
"metadata": {
"sensorId": 5578,
"type": "temperature"
},
"timestamp": {
"$date": "2021-05-18T02:00:00Z"
},
"temp": 14
},
{
"timestamp": {
"$date": "2021-05-18T02:00:00Z"
}
}
]
Expected output:
[
{
"_id": 0,
"metadata": {
"sensorId": 5578,
"type": "temperature"
},
"timestamp": {
"$date": "2021-05-18T00:00:00Z"
},
"temp": 12
},
{
"metadata": {
"sensorId": 5578
},
"timestamp": {
"$date": "2021-05-18T01:00:00Z"
}
},
{
"_id": 1,
"metadata": {
"sensorId": 5578,
"type": "temperature"
},
"timestamp": {
"$date": "2021-05-18T02:00:00Z"
},
"temp": 14
}
]