SSE: Add noData type (#51973)

When there is a single frame with no fields (e.g. splunk datasource) SSE errors when trying to figure out the data type. This frame needs to exist since this is where the executedQueryString metadata exists.

This adds a new return type to SSE to represent no data, so the original frame with its metadata can still be maintained.
This commit is contained in:
Kyle Brandt
2022-07-14 09:18:12 -04:00
committed by GitHub
parent 5d199a40b7
commit 05fd7eb047
5 changed files with 88 additions and 2 deletions
+10 -1
View File
@@ -117,6 +117,8 @@ func (e *State) walkUnary(node *parse.UnaryNode) (Results, error) {
newVal, err = e.unaryNumber(rt, node.OpStr)
case Series:
newVal, err = e.unarySeries(rt, node.OpStr)
case NoData:
newVal = NoData{}.New()
default:
return newResults, fmt.Errorf("can not perform a unary operation on type %v", rt.Type())
}
@@ -192,9 +194,16 @@ type Union struct {
// number of tags.
func union(aResults, bResults Results) []*Union {
unions := []*Union{}
if len(aResults.Values) == 0 || len(bResults.Values) == 0 {
aValueLen := len(aResults.Values)
bValueLen := len(bResults.Values)
if aValueLen == 0 || bValueLen == 0 {
return unions
}
if aValueLen == 1 || bValueLen == 1 {
if aResults.Values[0].Type() == parse.TypeNoData || bResults.Values[0].Type() == parse.TypeNoData {
return unions
}
}
for _, a := range aResults.Values {
for _, b := range bResults.Values {
var labels data.Labels