diff --git a/promql/engine_test.go b/promql/engine_test.go index fe1d017bc..886d2a92e 100644 --- a/promql/engine_test.go +++ b/promql/engine_test.go @@ -2455,10 +2455,11 @@ func TestSparseHistogramRate(t *testing.T) { require.NoError(t, test.Run()) engine := test.QueryEngine() - queryString := fmt.Sprintf("rate(%s[1m])", seriesName) + //queryString := fmt.Sprintf("rate(%s[1m])", seriesName) + queryString := fmt.Sprintf("%s", seriesName) qry, err := engine.NewInstantQuery(test.Queryable(), queryString, timestamp.Time(int64(5*time.Minute/time.Millisecond))) require.NoError(t, err) res := qry.Exec(test.Context()) require.NoError(t, res.Err) - // fmt.Println(res) + fmt.Println(res) } diff --git a/promql/value.go b/promql/value.go index 5e3863379..727808423 100644 --- a/promql/value.go +++ b/promql/value.go @@ -87,9 +87,13 @@ type Point struct { } func (p Point) String() string { - // TODO(beorn7): Support Histogram. - v := strconv.FormatFloat(p.V, 'f', -1, 64) - return fmt.Sprintf("%v @[%v]", v, p.T) + var s string + if p.H != nil { + s = p.H.String() + } else { + s = strconv.FormatFloat(p.V, 'f', -1, 64) + } + return fmt.Sprintf("%s @[%v]", s, p.T) } // MarshalJSON implements json.Marshaler. diff --git a/storage/memoized_iterator.go b/storage/memoized_iterator.go index 0c40bb9d0..9d4cc5207 100644 --- a/storage/memoized_iterator.go +++ b/storage/memoized_iterator.go @@ -80,7 +80,11 @@ func (b *MemoizedSeriesIterator) Seek(t int64) bool { if !b.ok { return false } - b.lastTime, _ = b.it.At() + if b.it.ChunkEncoding() == chunkenc.EncHistogram { + b.lastTime, _ = b.it.AtHistogram() + } else { + b.lastTime, _ = b.it.At() + } } if b.lastTime >= t { @@ -102,11 +106,19 @@ func (b *MemoizedSeriesIterator) Next() bool { } // Keep track of the previous element. - b.prevTime, b.prevValue = b.it.At() + if b.it.ChunkEncoding() == chunkenc.EncHistogram { + b.prevTime, b.prev + } else { + b.prevTime, b.prevValue = b.it.At() + } b.ok = b.it.Next() if b.ok { - b.lastTime, _ = b.it.At() + if b.it.ChunkEncoding() == chunkenc.EncHistogram { + b.lastTime, _ = b.it.AtHistogram() + } else { + b.lastTime, _ = b.it.At() + } } return b.ok