-
Type:
New Feature
-
Resolution: Unresolved
-
Priority:
Unknown
-
None
-
Affects Version/s: None
-
Component/s: Query
-
None
-
None
-
None
-
None
-
None
-
None
-
None
-
None
Support the HQL scalar COUNT subquery pattern over an embedded array via UNNEST, translating it to MongoDB's $filter + $size.
Example HQL:
SELECT c.id, (SELECT count(*) FROM UNNEST(c.lineItems) li WHERE li.qty > 4) FROM Cart c
Expected MQL:
{ "$addFields": { "_count": { "$size": { "$filter": {
"input": "$lineItems",
"cond": { "$gt": ["$$this.qty", 4] }
} } } } }
This shape returns the count of matching array elements as a scalar value per parent document. It maps naturally to $filter + $size without requiring $unwind.