SSE: Fix NoData when some series were no data but others not (#45867)

Co-authored-by: Santiago <santiagohernandez.1997@gmail.com>
pull/45619/head^2
Kyle Brandt 3 years ago committed by GitHub
parent 8a98354844
commit a578cf0f7c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 4
      pkg/expr/classic/classic.go
  2. 25
      pkg/expr/classic/classic_test.go
  3. 6
      pkg/expr/classic/reduce_test.go

@ -129,7 +129,7 @@ func (ccc *ConditionsCmd) Execute(ctx context.Context, vars mathexp.Vars) (mathe
}
thisCondFiring := firingCount > 0
thisCondNoData := nilReducedCount > 0
thisCondNoData := len(querySeriesSet.Values) == nilReducedCount
if i == 0 {
firing = thisCondFiring
@ -144,7 +144,7 @@ func (ccc *ConditionsCmd) Execute(ctx context.Context, vars mathexp.Vars) (mathe
noDataFound = noDataFound && thisCondNoData
}
if len(querySeriesSet.Values) == nilReducedCount {
if thisCondNoData {
matches = append(matches, EvalMatch{
Metric: "NoData",
})

@ -169,6 +169,31 @@ func TestConditionsCmdExecute(t *testing.T) {
return v
},
},
{
name: "single query and single condition - empty series and not empty series",
vars: mathexp.Vars{
"A": mathexp.Results{
Values: []mathexp.Value{
valBasedSeries(),
valBasedSeries(ptr.Float64(3)),
},
},
},
conditionsCmd: &ConditionsCmd{
Conditions: []condition{
{
QueryRefID: "A",
Reducer: classicReducer("avg"),
Operator: "and",
Evaluator: &thresholdEvaluator{Type: "gt", Threshold: .5},
},
}},
resultNumber: func() mathexp.Number {
v := valBasedNumber(ptr.Float64(1))
v.SetMeta([]EvalMatch{{Value: ptr.Float64(3)}})
return v
},
},
{
name: "single query and two conditions",
vars: mathexp.Vars{

@ -102,6 +102,12 @@ func TestReducer(t *testing.T) {
inputSeries: valBasedSeries(nil, nil, ptr.Float64(3), ptr.Float64(4)),
expectedNumber: valBasedNumber(ptr.Float64(2)),
},
{
name: "count_non_null with mixed null/real values",
reducer: classicReducer("count_non_null"),
inputSeries: valBasedSeries(nil, nil, ptr.Float64(3), ptr.Float64(4)),
expectedNumber: valBasedNumber(ptr.Float64(2)),
},
{
name: "count_non_null with no values",
reducer: classicReducer("count_non_null"),

Loading…
Cancel
Save