SSE: Fix math expression to support NoData results (#61721)

* update perFloat to support NoData
* update union to correctly handle no-data
This commit is contained in:
Yuri Tseretyan
2023-01-20 09:53:03 -05:00
committed by GitHub
parent d0cf7ff8e9
commit c0913ce718
5 changed files with 141 additions and 1 deletions
+14
View File
@@ -7,6 +7,7 @@ import (
"runtime"
"github.com/grafana/grafana-plugin-sdk-go/data"
"github.com/grafana/grafana/pkg/expr/mathexp/parse"
)
@@ -201,6 +202,11 @@ func union(aResults, bResults Results) []*Union {
}
if aValueLen == 1 || bValueLen == 1 {
if aResults.Values[0].Type() == parse.TypeNoData || bResults.Values[0].Type() == parse.TypeNoData {
unions = append(unions, &Union{
Labels: nil,
A: aResults.Values[0],
B: bResults.Values[0],
})
return unions
}
}
@@ -285,6 +291,8 @@ func (e *State) walkBinary(node *parse.BinaryNode) (Results, error) {
// Scalar op Series
case Series:
value, err = e.biSeriesNumber(uni.Labels, node.OpStr, bt, aFloat, false)
case NoData:
value = uni.B
default:
return res, fmt.Errorf("not implemented: binary %v on %T and %T", node.OpStr, uni.A, uni.B)
}
@@ -301,6 +309,8 @@ func (e *State) walkBinary(node *parse.BinaryNode) (Results, error) {
// case Series op Series
case Series:
value, err = e.biSeriesSeries(uni.Labels, node.OpStr, at, bt)
case NoData:
value = uni.B
default:
return res, fmt.Errorf("not implemented: binary %v on %T and %T", node.OpStr, uni.A, uni.B)
}
@@ -315,9 +325,13 @@ func (e *State) walkBinary(node *parse.BinaryNode) (Results, error) {
value, err = e.biScalarNumber(uni.Labels, node.OpStr, at, bFloat, true)
case Series:
value, err = e.biSeriesNumber(uni.Labels, node.OpStr, bt, aFloat, false)
case NoData:
value = uni.B
default:
return res, fmt.Errorf("not implemented: binary %v on %T and %T", node.OpStr, uni.A, uni.B)
}
case NoData:
value = uni.A
default:
return res, fmt.Errorf("not implemented: binary %v on %T and %T", node.OpStr, uni.A, uni.B)
}