mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2024-11-21 14:44:00 +00:00
app/vmselect/promql: update logic to account for metricsql rollup funcs
MetricsQL rollup funcs can contain not only rollup expression, but many other expressions such as `phi`, label names, etc. So changing the logic to check if rollup function contains at least one rollup expr. Signed-off-by: hagen1778 <roman@victoriametrics.com>
This commit is contained in:
parent
14b9ef1e4d
commit
f6cafaab14
2 changed files with 17 additions and 2 deletions
|
@ -432,10 +432,11 @@ func noImplicitConversionRequired(e metricsql.Expr, isSubExpr bool) bool {
|
|||
}
|
||||
fe := e.(*metricsql.FuncExpr)
|
||||
isRollupFn := getRollupFunc(fe.Name) != nil
|
||||
var hasAtLeastOneRollupExpr bool
|
||||
for _, arg := range exp.Args {
|
||||
_, isRollupExpr := arg.(*metricsql.RollupExpr)
|
||||
if (isRollupExpr && !isRollupFn) || (!isRollupExpr && isRollupFn) {
|
||||
return false
|
||||
if !hasAtLeastOneRollupExpr && isRollupExpr {
|
||||
hasAtLeastOneRollupExpr = true
|
||||
}
|
||||
if isRollupFn {
|
||||
isSubExpr = true
|
||||
|
@ -444,6 +445,9 @@ func noImplicitConversionRequired(e metricsql.Expr, isSubExpr bool) bool {
|
|||
return false
|
||||
}
|
||||
}
|
||||
if (isRollupFn && !hasAtLeastOneRollupExpr) || (!isRollupFn && hasAtLeastOneRollupExpr) {
|
||||
return false
|
||||
}
|
||||
case *metricsql.RollupExpr:
|
||||
if _, ok := exp.Expr.(*metricsql.MetricExpr); ok {
|
||||
return exp.Step == nil
|
||||
|
|
|
@ -9488,6 +9488,17 @@ func TestNoImplicitConversionRequiredTrue(t *testing.T) {
|
|||
f("max_over_time(rate(my_counter_total[5m])[1h:1m])[5m:1m]")
|
||||
f("max_over_time(rate(my_counter_total[5m])[1h:])[5m:]")
|
||||
|
||||
// this query will fail the test because it contains subquery
|
||||
// f(`aggr_over_time(("rate", "increase"), foo[1h])`)
|
||||
|
||||
// metricsql rollup functions
|
||||
f(`predict_linear(foo{}[1h], 86400)`)
|
||||
f(`quantile_over_time(0.99, foo[1h])`)
|
||||
f(`quantiles_over_time("phi", 0.5, 0.99, foo[1h])`)
|
||||
f(`count_ne_over_time(foo[1h], 1)`)
|
||||
f(`count_values_over_time("label", foo[1h])`)
|
||||
f(`holt_winters(foo[1h], 0, 1)`)
|
||||
|
||||
f(`
|
||||
WITH (
|
||||
cpuSeconds = node_cpu_seconds_total{instance=~"$node:$port",job=~"$job"},
|
||||
|
|
Loading…
Reference in a new issue