mirror of
https://github.com/prometheus/prometheus.git
synced 2025-02-21 03:16:00 -08:00
Fix scalar-vector comparisons (#5454)
* Fix scalar-vector comparisons Fixes https://github.com/prometheus/prometheus/issues/5452 Signed-off-by: Julius Volz <julius.volz@gmail.com>
This commit is contained in:
parent
46660a0745
commit
bc1c7f1809
|
@ -24,6 +24,7 @@
|
|||
* [BUGFIX] Set TLSHandshakeTimeout in HTTP transport. common#179
|
||||
* [BUGFIX] Use fsync to be more resilient to machine crashes. tsdb#573 tsdb#578
|
||||
* [BUGFIX] Keep series that are still in WAL in checkpoints. tsdb#577
|
||||
* [BUGFIX] Fix output sample values for scalar-to-vector comparison operations. #5454
|
||||
|
||||
## 2.8.1 / 2019-03-28
|
||||
|
||||
|
|
|
@ -1581,6 +1581,11 @@ func (ev *evaluator) VectorscalarBinop(op ItemType, lhs Vector, rhs Scalar, swap
|
|||
lv, rv = rv, lv
|
||||
}
|
||||
value, keep := vectorElemBinop(op, lv, rv)
|
||||
// Catch cases where the scalar is the LHS in a scalar-vector comparison operation.
|
||||
// We want to always keep the vector element value as the output value, even if it's on the RHS.
|
||||
if op.isComparisonOperator() && swap {
|
||||
value = rv
|
||||
}
|
||||
if returnBool {
|
||||
if keep {
|
||||
value = 1.0
|
||||
|
|
2
promql/testdata/operators.test
vendored
2
promql/testdata/operators.test
vendored
|
@ -220,7 +220,7 @@ eval instant at 50m SUM(http_requests) BY (job) > 1000
|
|||
{job="app-server"} 2600
|
||||
|
||||
eval instant at 50m 1000 < SUM(http_requests) BY (job)
|
||||
{job="app-server"} 1000
|
||||
{job="app-server"} 2600
|
||||
|
||||
eval instant at 50m SUM(http_requests) BY (job) <= 1000
|
||||
{job="api-server"} 1000
|
||||
|
|
Loading…
Reference in a new issue