Skip to content

Fix aggregate processor actions concludeGroup#6147

Merged
kkondaka merged 3 commits into
opensearch-project:mainfrom
kkondaka:aggregate-action-fix
Oct 9, 2025
Merged

Fix aggregate processor actions concludeGroup#6147
kkondaka merged 3 commits into
opensearch-project:mainfrom
kkondaka:aggregate-action-fix

Conversation

@kkondaka

@kkondaka kkondaka commented Oct 8, 2025

Copy link
Copy Markdown
Collaborator

Description

Fix aggregate processor actions concludeGroup. concludeGroup should handle groupState being empty.
If identification keys contain null values, then handleEvent of aggregate processor actions do not update the groupState and if such group is concluded, it can result in concludeGroup to throw exceptions. If the groupState is empty, it is better to return null AggregateActionOutput.

Issues Resolved

Resolves #[Issue number to be closed when this PR is merged]

Check List

  • [X ] New functionality includes testing.
  • New functionality has a documentation issue. Please link to it in this PR.
    • New functionality has javadoc added
  • [ X] Commits are signed with a real name per the DCO

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.

Signed-off-by: Kondaka <krishkdk@amazon.com>
Signed-off-by: Kondaka <krishkdk@amazon.com>

@dlvenable dlvenable left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this fix @kkondaka !


final List<Event> concludeGroupEvents = actionOutput != null ? actionOutput.getEvents() : null;
if (!concludeGroupEvents.isEmpty()) {
if (concludeGroupEvents != null && !concludeGroupEvents.isEmpty()) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a unit test for this new condition.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have added a test for the new condition in AggregateProecssorIT.java. Not sure if unit test really makes any difference.

}

@Test
void concludeGroup_with_empty_groupState_handled_correctly() throws NoSuchFieldException, IllegalAccessException {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

concludeGroup_with_empty_groupState_returns_null

}

@Test
void testHistogramAggregationWithEmptyGroupState() throws NoSuchFieldException, IllegalAccessException {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

testHistogramAggregationWithEmptyGroupStateReturnsNull

}

@Test
void testCountAggregationWithEmptyGroupState() {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

testCountAggregationWithEmptyGroupStateReturnsNull

Signed-off-by: Kondaka <krishkdk@amazon.com>
public AggregateActionOutput concludeGroup(final AggregateActionInput aggregateActionInput) {
GroupState groupState = aggregateActionInput.getGroupState();
if (groupState.isEmpty()) {
return null;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are we sure we should return null here? Why not return the output with empty list?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Both are treated the same way. So, it really doesn't matter.

@kkondaka kkondaka merged commit 4071ed0 into opensearch-project:main Oct 9, 2025
43 of 47 checks passed
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.

3 participants