Skip to content

Allow Mongo group-by on an aliased function expression - #327

Open
bhubam wants to merge 2 commits into
mainfrom
function-group-by
Open

bhubam wants to merge 2 commits into
mainfrom
function-group-by

Conversation

@bhubam

@bhubam bhubam commented Sep 23, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Add an optional alias on FunctionExpression so a function can be used as a Mongo group key.
  • When the alias is set, $addFields materializes the function and $group groups by that field. A blank alias still fails with the existing unsupported-operation error.
  • Covers the actor interval bucket (INTERVAL_START_TIME), which is floor(lastActivity / interval) * interval.

Merge order

Merge this before the entity-service interval change. Entity-service will pick up FunctionExpression.alias through a BOM upgrade; this PR does not publish a version.

Test plan

  • MongoFunctionGroupByTest asserts $addFields for INTERVAL_START_TIME, $group._id references that field, and the projection reads $_id.INTERVAL_START_TIME.
  • CI on this PR.

Interval buckets are computed in $addFields and grouped by that field instead of the function itself.
@codecov

codecov Bot commented Sep 23, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 54.54545% with 5 lines in your changes missing coverage. Please review.
✅ Project coverage is 81.16%. Comparing base (db61d59) to head (8696769).

Files with missing lines Patch % Lines
...o/query/parser/MongoGroupTypeExpressionParser.java 40.00% 2 Missing and 1 partial ⚠️
.../core/documentstore/parser/GroupByAliasGetter.java 50.00% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff            @@
##               main     #327   +/-   ##
=========================================
  Coverage     81.16%   81.16%           
- Complexity     1679     1690   +11     
=========================================
  Files           243      243           
  Lines          7762     7769    +7     
  Branches        769      771    +2     
=========================================
+ Hits           6300     6306    +6     
+ Misses          967      966    -1     
- Partials        495      497    +2     
Flag Coverage Δ
integration 81.16% <54.54%> (+<0.01%) ⬆️
unit 58.73% <54.54%> (+0.23%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@github-actions

github-actions Bot commented Sep 23, 2026 •

Copy link
Copy Markdown

Test Results

  128 files  +1    128 suites  +1   38s ⏱️ +5s
  890 tests +1    889 ✅ +1  1 💤 ±0  0 ❌ ±0 
1 260 runs  +1  1 259 ✅ +1  1 💤 ±0  0 ❌ ±0 

Results for commit 8696769. ± Comparison against base commit db61d59.

♻️ This comment has been updated with latest results.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant