Skip to content

Commit

Permalink
fixing funcs
Browse files Browse the repository at this point in the history
Signed-off-by: Pedro Tanaka <pedro.tanaka@shopify.com>
  • Loading branch information
pedro-stanaka committed May 6, 2024
1 parent 5ced8c3 commit 8fd13b6
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 25 deletions.
24 changes: 0 additions & 24 deletions pkg/api/query/v1_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -749,30 +749,6 @@ func TestQueryAnalyzeEndpoints(t *testing.T) {
QueryAnalysis: queryTelemetry{},
},
},
{
endpoint: api.queryRange,
query: url.Values{
"query": []string{"xrate(up[2m])"},
"start": []string{"0"},
"end": []string{"500"},
},
response: &queryData{
ResultType: parser.ValueTypeMatrix,
Result: promql.Matrix{
promql.Series{
Floats: func(end, step float64) []promql.FPoint {
var res []promql.FPoint
for v := float64(0); v <= end; v += step {
res = append(res, promql.FPoint{F: v, T: timestamp.FromTime(start.Add(time.Duration(v) * time.Second))})
}
return res
}(500, 1),
Metric: nil,
},
},
QueryAnalysis: queryTelemetry{},
},
},
{
endpoint: api.queryRange,
query: url.Values{
Expand Down
9 changes: 8 additions & 1 deletion pkg/extpromql/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,14 @@ import (

// ParseExpr parses the input PromQL expression and returns the parsed representation.
func ParseExpr(input string) (parser.Expr, error) {
p := parser.NewParser(input, parser.WithFunctions(function.XFunctions))
allFuncs := make(map[string]*parser.Function, len(function.XFunctions)+len(parser.Functions))
for k, v := range parser.Functions {
allFuncs[k] = v
}
for k, v := range function.XFunctions {
allFuncs[k] = v
}
p := parser.NewParser(input, parser.WithFunctions(allFuncs))
defer p.Close()
return p.ParseExpr()
}
Expand Down

0 comments on commit 8fd13b6

Please sign in to comment.