Skip to content

Commit

Permalink
Fix build failure
Browse files Browse the repository at this point in the history
  • Loading branch information
harry671003 committed Feb 14, 2023
1 parent 5bebbf4 commit 5bc92aa
Showing 1 changed file with 15 additions and 11 deletions.
26 changes: 15 additions & 11 deletions pkg/queryfrontend/queryinstant_codec.go
Expand Up @@ -7,7 +7,6 @@ import (
"bytes"
"context"
"encoding/json"
"errors"
"io"
"net/http"
"net/url"
Expand All @@ -17,6 +16,7 @@ import (

"github.com/opentracing/opentracing-go"
otlog "github.com/opentracing/opentracing-go/log"
"github.com/pkg/errors"
"github.com/prometheus/common/model"
"github.com/weaveworks/common/httpgrpc"

Expand Down Expand Up @@ -340,23 +340,27 @@ func vectorMerge(resps []*queryrange.PrometheusInstantQueryResponse) (*queryrang

func parseQueryForSort(q string) (bool, bool, error) {
expr, err := promqlparser.ParseExpr(q)
if err != nil {
return false, false, err
}
var sortAsc bool = false
var sortDesc bool = false
promqlparser.Inspect(expr, func(n promqlparser.Node, _ []promqlparser.Node) error {
if call, ok := n.(*promqlparser.Call); ok {
if call.Func.Name == "sort" {
sortAsc = true
return errors.New("done")
}
if call.Func.Name == "sort_desc" {
sortDesc = true
return errors.New("done")
if n, ok := n.(*promqlparser.Call); ok {
if n.Func != nil {
if n.Func.Name == "sort" {
sortAsc = true
return errors.New("done")
}
if n.Func.Name == "sort_desc" {
sortDesc = true
return errors.New("done")
}
}
}
return nil
})

return sortAsc, sortDesc, err
return sortAsc, sortDesc, nil
}

func matrixMerge(resps []*queryrange.PrometheusInstantQueryResponse) *queryrange.Matrix {
Expand Down

0 comments on commit 5bc92aa

Please sign in to comment.