mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Make tsdb dataframes response able to carry encoded/decoded frames (#25454)
Make tsdb dataframes response able to carry encoded and/or decoded frames
This commit is contained in:
committed by
GitHub
parent
de1dc57242
commit
53175a41c9
@@ -7,7 +7,6 @@ import (
|
||||
|
||||
gocontext "context"
|
||||
|
||||
"github.com/grafana/grafana-plugin-sdk-go/data"
|
||||
"github.com/grafana/grafana/pkg/bus"
|
||||
"github.com/grafana/grafana/pkg/components/null"
|
||||
"github.com/grafana/grafana/pkg/components/simplejson"
|
||||
@@ -174,7 +173,7 @@ func (c *QueryCondition) executeQuery(context *alerting.EvalContext, timeRange *
|
||||
useDataframes := v.Dataframes != nil && (v.Series == nil || len(v.Series) == 0)
|
||||
|
||||
if useDataframes { // convert the dataframes to tsdb.TimeSeries
|
||||
frames, err := data.UnmarshalArrowFrames(v.Dataframes)
|
||||
frames, err := v.Dataframes.Decoded()
|
||||
if err != nil {
|
||||
return nil, errutil.Wrap("tsdb.HandleRequest() failed to unmarshal arrow dataframes from bytes", err)
|
||||
}
|
||||
|
||||
@@ -55,7 +55,7 @@ func TestQueryCondition(t *testing.T) {
|
||||
|
||||
Convey("should fire when avg is above 100 on dataframe", func() {
|
||||
ctx.frame = data.NewFrame("",
|
||||
data.NewField("time", nil, []time.Time{time.Now()}),
|
||||
data.NewField("time", nil, []time.Time{time.Now(), time.Now()}),
|
||||
data.NewField("val", nil, []int64{120, 150}),
|
||||
)
|
||||
cr, err := ctx.exec()
|
||||
@@ -75,7 +75,7 @@ func TestQueryCondition(t *testing.T) {
|
||||
|
||||
Convey("Should not fire when avg is below 100 on dataframe", func() {
|
||||
ctx.frame = data.NewFrame("",
|
||||
data.NewField("time", nil, []time.Time{time.Now()}),
|
||||
data.NewField("time", nil, []time.Time{time.Now(), time.Now()}),
|
||||
data.NewField("val", nil, []int64{12, 47}),
|
||||
)
|
||||
cr, err := ctx.exec()
|
||||
@@ -198,12 +198,8 @@ func (ctx *queryConditionTestContext) exec() (*alerting.ConditionResult, error)
|
||||
}
|
||||
|
||||
if ctx.frame != nil {
|
||||
bFrame, err := ctx.frame.MarshalArrow()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
qr = &tsdb.QueryResult{
|
||||
Dataframes: [][]byte{bFrame},
|
||||
Dataframes: tsdb.NewDecodedDataFrames(data.Frames{ctx.frame}),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user