From 55f9147b440d621066c32a3978c5360272592e33 Mon Sep 17 00:00:00 2001 From: ziollek Date: Fri, 15 Oct 2021 16:03:11 +0200 Subject: [PATCH] Add atan2 to scalar operators - issue #9485 (#9515) * Add atan2 to scalar operators Signed-off-by: Tomasz Ziolkowski --- promql/engine.go | 2 ++ promql/testdata/operators.test | 6 ++++++ 2 files changed, 8 insertions(+) diff --git a/promql/engine.go b/promql/engine.go index e5dbcd2d77..5d530f34a7 100644 --- a/promql/engine.go +++ b/promql/engine.go @@ -2085,6 +2085,8 @@ func scalarBinop(op parser.ItemType, lhs, rhs float64) float64 { return btos(lhs >= rhs) case parser.LTE: return btos(lhs <= rhs) + case parser.ATAN2: + return math.Atan2(lhs, rhs) } panic(errors.Errorf("operator %q not allowed for Scalar operations", op)) } diff --git a/promql/testdata/operators.test b/promql/testdata/operators.test index a6072eef31..7056213c9e 100644 --- a/promql/testdata/operators.test +++ b/promql/testdata/operators.test @@ -481,3 +481,9 @@ eval instant at 5m trigy atan2 trigx eval instant at 5m trigy atan2 trigNaN trigy{} NaN + +eval instant at 5m 10 atan2 20 + 0.4636476090008061 + +eval instant at 5m 10 atan2 NaN + NaN