TestData DS: Make Random Walk queries compatible with Data Plane (#103966)
* DataData DS: Add Frame type to Random Walk queries
* Time column should not be nullable
Conversion for the SQL (server-side) expression was failing with:
`failed to convert data frames to long format for sql: missing time field`
Because we weren't seeing a match at:
`if f.Type() == data.FieldTypeTime {`]
here:
https://github.com/grafana/grafana/blob/acb0e6b609fc5b099e9ba6c67000aa3a0029974d/pkg/expr/convert_to_full_long.go#L155
The DataPlane docs (https://grafana.com/developers/dataplane/timeseries)
state that:
> - The Time field(s):
> - Should have no null values
So making the fix here
This commit is contained in:
@@ -715,7 +715,7 @@ func RandomWalk(query backend.DataQuery, model kinds.TestDataQuery, index int) *
|
||||
max = *model.Max
|
||||
}
|
||||
|
||||
timeVec := make([]*time.Time, 0)
|
||||
timeVec := make([]time.Time, 0)
|
||||
floatVec := make([]*float64, 0)
|
||||
|
||||
walker := startValue
|
||||
@@ -737,7 +737,7 @@ func RandomWalk(query backend.DataQuery, model kinds.TestDataQuery, index int) *
|
||||
// skip value
|
||||
} else {
|
||||
t := time.Unix(timeWalkerMs/int64(1e+3), (timeWalkerMs%int64(1e+3))*int64(1e+6))
|
||||
timeVec = append(timeVec, &t)
|
||||
timeVec = append(timeVec, t)
|
||||
floatVec = append(floatVec, &nextValue)
|
||||
}
|
||||
|
||||
@@ -758,6 +758,7 @@ func RandomWalk(query backend.DataQuery, model kinds.TestDataQuery, index int) *
|
||||
"customStat": 10,
|
||||
},
|
||||
})
|
||||
frame.Meta.Type = data.FrameTypeTimeSeriesMulti
|
||||
|
||||
return frame
|
||||
}
|
||||
@@ -902,7 +903,7 @@ func predictableSeries(timeRange backend.TimeRange, timeStep, length int64, getV
|
||||
wavePeriod := timeStep * length
|
||||
maxPoints := 10000 // Don't return too many points
|
||||
|
||||
timeVec := make([]*time.Time, 0)
|
||||
timeVec := make([]time.Time, 0)
|
||||
floatVec := make([]*float64, 0)
|
||||
|
||||
for i := 0; i < maxPoints && timeCursor < to; i++ {
|
||||
@@ -912,7 +913,7 @@ func predictableSeries(timeRange backend.TimeRange, timeStep, length int64, getV
|
||||
}
|
||||
|
||||
t := time.Unix(timeCursor/int64(1e+3), (timeCursor%int64(1e+3))*int64(1e+6))
|
||||
timeVec = append(timeVec, &t)
|
||||
timeVec = append(timeVec, t)
|
||||
floatVec = append(floatVec, val)
|
||||
|
||||
timeCursor += timeStep
|
||||
|
||||
Reference in New Issue
Block a user