fix: use fill gaps only for time series panel types (#5387)

This commit is contained in:
Srikanth Chekuri 2024-07-01 14:06:28 +05:30 committed by GitHub
parent 02106277a6
commit b0b69c83db
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 39 additions and 0 deletions

View File

@ -46,6 +46,9 @@ func fillGap(series *v3.Series, start, end, step int64) *v3.Series {
// TODO(srikanthccv): can WITH FILL be perfect substitute for all cases https://clickhouse.com/docs/en/sql-reference/statements/select/order-by#order-by-expr-with-fill-modifier
func FillGaps(results []*v3.Result, params *v3.QueryRangeParamsV3) {
if params.CompositeQuery.PanelType != v3.PanelTypeGraph {
return
}
for _, result := range results {
// A `result` item in `results` contains the query result for individual query.
// If there are no series in the result, we add empty series and `fillGap` adds all zeros

View File

@ -43,6 +43,7 @@ func TestFillGaps(t *testing.T) {
Start: 1000,
End: 5000,
CompositeQuery: &v3.CompositeQuery{
PanelType: v3.PanelTypeGraph,
BuilderQueries: map[string]*v3.BuilderQuery{
"query1": {
QueryName: "query1",
@ -82,6 +83,7 @@ func TestFillGaps(t *testing.T) {
Start: 1000,
End: 5000,
CompositeQuery: &v3.CompositeQuery{
PanelType: v3.PanelTypeGraph,
BuilderQueries: map[string]*v3.BuilderQuery{
"query1": {
QueryName: "query1",
@ -121,6 +123,7 @@ func TestFillGaps(t *testing.T) {
Start: 1000,
End: 5000,
CompositeQuery: &v3.CompositeQuery{
PanelType: v3.PanelTypeGraph,
BuilderQueries: map[string]*v3.BuilderQuery{
"query1": {
QueryName: "query1",
@ -142,6 +145,39 @@ func TestFillGaps(t *testing.T) {
}),
},
},
{
name: "Single series with gaps and panel type is not graph",
results: []*v3.Result{
createResult("query1", []*v3.Series{
createSeries([]v3.Point{
{Timestamp: 1000, Value: 1.0},
{Timestamp: 3000, Value: 3.0},
}),
}),
},
params: &v3.QueryRangeParamsV3{
Start: 1000,
End: 5000,
CompositeQuery: &v3.CompositeQuery{
PanelType: v3.PanelTypeList,
BuilderQueries: map[string]*v3.BuilderQuery{
"query1": {
QueryName: "query1",
Expression: "query1",
StepInterval: 1,
},
},
},
},
expected: []*v3.Result{
createResult("query1", []*v3.Series{
createSeries([]v3.Point{
{Timestamp: 1000, Value: 1.0},
{Timestamp: 3000, Value: 3.0},
}),
}),
},
},
}
// Execute test cases