PostgreSQL: __unixEpochGroup to support arithmetic expression as argument (#46764)

* __unixEpochGroup to support arithmetic argument

Following call generates wrong expression : 
 
$__unixEpochGroupAlias(height+42,$__interval)

=> floor(height+42/60)*60 AS "time"

instead of

=> floor((height+42)/60)*60 AS "time"

* Update test of __unixEpochGroup related to issue #46764
This commit is contained in:
Julien NOEL
2022-03-26 18:44:14 +01:00
committed by GitHub
parent 7bc821baf2
commit f4b6c4019c
2 changed files with 4 additions and 4 deletions

View File

@ -146,7 +146,7 @@ func (m *postgresMacroEngine) evaluateMacro(timeRange backend.TimeRange, query *
return "", err
}
}
return fmt.Sprintf("floor(%s/%v)*%v", args[0], interval.Seconds(), interval.Seconds()), nil
return fmt.Sprintf("floor((%s)/%v)*%v", args[0], interval.Seconds(), interval.Seconds()), nil
case "__unixEpochGroupAlias":
tg, err := m.evaluateMacro(timeRange, query, "__unixEpochGroup", args)
if err == nil {