Skip to content

Commit

Permalink
Merge branch 'develop' into fix-formatter
Browse files Browse the repository at this point in the history
  • Loading branch information
srikanthccv authored Jul 1, 2024
2 parents eb32fce + b0b69c8 commit 56fbcb0
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 0 deletions.
3 changes: 3 additions & 0 deletions pkg/query-service/postprocess/gaps.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
36 changes: 36 additions & 0 deletions pkg/query-service/postprocess/gaps_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand All @@ -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
Expand Down

0 comments on commit 56fbcb0

Please sign in to comment.