Conversation
Interval buckets are computed in $addFields and grouped by that field instead of the function itself.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #327 +/- ##
============================================
+ Coverage 81.16% 81.23% +0.06%
- Complexity 1679 1698 +19
============================================
Files 243 243
Lines 7762 7780 +18
Branches 769 771 +2
============================================
+ Hits 6300 6320 +20
+ Misses 967 962 -5
- Partials 495 498 +3
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
Two cases:
|
A null or blank function alias still fails. When the selection alias differs, group by the function alias and project that _id field under the selection name. Co-authored-by: Cursor <cursoragent@cursor.com>
|
Null or blank function alias still throws UnsupportedOperationException (Grouping by a function ... is not yet supported). No $addFields stage. Covered by rejectsFunctionGroupByWhenAliasIsMissing (null, "", and " "). If the function alias and the selection alias differ (bar vs foo): $addFields writes the bucket as bar |
Summary
FunctionExpressionso a function can be used as a Mongo group key.$addFieldsmaterializes the function and$groupgroups by that field. A blank alias still fails with the existing unsupported-operation error.INTERVAL_START_TIME), which isfloor(lastActivity / interval) * interval.Merge order
Merge this before the entity-service interval change. Entity-service will pick up
FunctionExpression.aliasthrough a BOM upgrade; this PR does not publish a version.Test plan
MongoFunctionGroupByTestasserts$addFieldsforINTERVAL_START_TIME,$group._idreferences that field, and the projection reads$_id.INTERVAL_START_TIME.