Skip to content

feat(aggregation): expose extra fields for aggregations#2827

Closed
congx4 wants to merge 3 commits intomainfrom
congxie/supportAgg
Closed

feat(aggregation): expose extra fields for aggregations#2827
congx4 wants to merge 3 commits intomainfrom
congxie/supportAgg

Conversation

@congx4
Copy link
Collaborator

@congx4 congx4 commented Feb 3, 2026

Summary

This change modifies the Average aggregation to return sum and count alongside the computed average value, enabling downstream systems to properly merge results across multiple query steps.

Changes

  • Add AverageMetricResult struct with value, sum, and count fields
  • Add sum() and count() getter methods to IntermediateAverage
  • Update MetricResult::Average to use AverageMetricResult
  • Update finalization to populate sum/count from intermediate result
  • Update tests to expect new JSON format

JSON Output Change

Before:

{ "value": 2.5 }

After:

{ "value": 2.5, "sum": 15.0, "count": 6 }

This change modifies the Average aggregation to return sum and count
alongside the computed average value, enabling downstream systems to
properly merge results across multiple query steps.

Changes:
- Add AverageMetricResult struct with value, sum, and count fields
- Add sum() and count() getter methods to IntermediateAverage
- Update MetricResult::Average to use AverageMetricResult
- Update finalization to populate sum/count from intermediate result
- Update tests to expect new JSON format

JSON output changes from:
  { "value": 2.5 }
to:
  { "value": 2.5, "sum": 15.0, "count": 6 }

This is a breaking change for JSON consumers expecting the old format.
@PSeitz
Copy link
Collaborator

PSeitz commented Feb 3, 2026

IntermediateAverage is already used in quickwit as an intermediate result to merge results

This change extends the multi-step query support to percentiles and
cardinality aggregations by exposing their underlying sketches.

Changes:
- Add CardinalityMetricResult struct with value and HLL sketch
- Update PercentilesMetricResult to include DDSketch
- Update MetricResult::Cardinality to use CardinalityMetricResult
- Update finalization to include sketches in results
- Add tests verifying sketch data is present in results

JSON output changes:

Percentiles:
  Before: { "values": {...} }
  After:  { "values": {...}, "sketch": {...} }

Cardinality:
  Before: { "value": 10.0 }
  After:  { "value": 10.0, "sketch": {...} }

The sketch fields enable downstream systems to merge results across
multiple query steps using the raw sketch data.
@congx4
Copy link
Collaborator Author

congx4 commented Feb 4, 2026

IntermediateAverage is already used in quickwit as an intermediate result to merge results

While reusing IntermediateAverage avoids boilerplate, my concern is backward compatibility. Exposing the intermediate struct as the final result produces a breaking change for downstream consumers like Quickwit. Introducing AverageMetricResult preserves the expected value field.

@congx4 congx4 changed the title feat(aggregation): expose sum and count in Average metric result feat(aggregation): expose extra fields for aggregations Feb 4, 2026
@congx4 congx4 closed this Feb 6, 2026
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.

2 participants