Skip to content

Commit

Permalink
Ignore native histograms when aggregating with std var/dev
Browse files Browse the repository at this point in the history
Signed-off-by: Jeanette Tan <jeanette.tan@grafana.com>
  • Loading branch information
zenador committed May 11, 2023
1 parent 31353ed commit 0fcf0a7
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions promql/engine.go
Original file line number Diff line number Diff line change
Expand Up @@ -2568,6 +2568,8 @@ func (ev *evaluator) aggregation(op parser.ItemType, grouping []string, without
case op == parser.AVG:
newAgg.histogramMean = s.H.Copy()
newAgg.hasHistogram = true
case op == parser.STDVAR || op == parser.STDDEV:
newAgg.groupCount = 0
}

result[groupingKey] = newAgg
Expand Down Expand Up @@ -2683,10 +2685,12 @@ func (ev *evaluator) aggregation(op parser.ItemType, grouping []string, without
group.groupCount++

case parser.STDVAR, parser.STDDEV:
group.groupCount++
delta := s.F - group.floatMean
group.floatMean += delta / float64(group.groupCount)
group.floatValue += delta * (s.F - group.floatMean)
if s.H == nil { // Ignore native histograms.
group.groupCount++
delta := s.F - group.floatMean
group.floatMean += delta / float64(group.groupCount)
group.floatValue += delta * (s.F - group.floatMean)
}

case parser.TOPK:
// We build a heap of up to k elements, with the smallest element at heap[0].
Expand Down

0 comments on commit 0fcf0a7

Please sign in to comment.