-
Type:
Bug
-
Resolution: Unresolved
-
Priority:
Minor - P4
-
None
-
Affects Version/s: None
-
Component/s: None
-
Query Optimization
-
ALL
-
None
-
None
-
None
-
None
-
None
-
None
-
None
The DependencyGraph public canPathBeArray() method will correctly determine the arrayness of fields, even when the path traverses into constants, renames or subpipelines.
For example:
{$lookup: {as: 'a', pipeline: [{$set: {'b': 1}}]}}
{$unwind: "$a"}
canPathBeArray(a.b) will check the arrayness for b in the subpipeline and return false.
However, in this same case, if the fields are later modified or projected, the arrayness information is lost and the graph conservatively says "can be array".
{$lookup: {as: 'a', ...}}
{$unwind: "$a"}
{$project: {"a.b": 1}}
canPathBeArray(a.b) will return false.
This is because internally, when processing "a.b":1, we have a different simplified implementation, which does not handle the prefix match (kShadowed) case as fully as the public API.
This would also affect the case when "a" is a rename, or a constant.
The code should be unified which would provide more complete arrayness information always.