From 309e020c0a3eb3199828a0512aa2d604cd692afc Mon Sep 17 00:00:00 2001 From: Levi Harrison Date: Mon, 23 Aug 2021 20:04:00 -0400 Subject: [PATCH 01/17] Added functions Signed-off-by: Levi Harrison --- promql/functions.go | 74 ++++++++++++++++++++++++++++++++++++++ promql/parser/functions.go | 57 +++++++++++++++++++++++++++-- 2 files changed, 128 insertions(+), 3 deletions(-) diff --git a/promql/functions.go b/promql/functions.go index d72b4caf65..746dd3fd58 100644 --- a/promql/functions.go +++ b/promql/functions.go @@ -570,6 +570,70 @@ func funcLog10(vals []parser.Value, args parser.Expressions, enh *EvalNodeHelper return simpleFunc(vals, enh, math.Log10) } +// === sin(Vector parser.ValueTypeVector) Vector === +func funcSin(vals []parser.Value, args parser.Expressions, enh *EvalNodeHelper) Vector { + return simpleFunc(vals, enh, math.Sin) +} + +// === cos(Vector parser.ValueTypeVector) Vector === +func funcCos(vals []parser.Value, args parser.Expressions, enh *EvalNodeHelper) Vector { + return simpleFunc(vals, enh, math.Cos) +} + +// === tan(Vector parser.ValueTypeVector) Vector === +func funcTan(vals []parser.Value, args parser.Expressions, enh *EvalNodeHelper) Vector { + return simpleFunc(vals, enh, math.Tan) +} + +// == asin(Vector parser.ValueTypeVector) Vector === +func funcAsin(vals []parser.Value, args parser.Expressions, enh *EvalNodeHelper) Vector { + return simpleFunc(vals, enh, math.Asin) +} + +// == acos(Vector parser.ValueTypeVector) Vector === +func funcAcos(vals []parser.Value, args parser.Expressions, enh *EvalNodeHelper) Vector { + return simpleFunc(vals, enh, math.Acos) +} + +// == atan(Vector parser.ValueTypeVector) Vector === +func funcAtan(vals []parser.Value, args parser.Expressions, enh *EvalNodeHelper) Vector { + return simpleFunc(vals, enh, math.Atan) +} + +// === atan2(Vector1, Vector2 parser.ValueTypeVector) Vector === +func funcAtan2(vals []parser.Value, args parser.Expressions, enh *EvalNodeHelper) Vector { + y := vals[0].(Vector) + x := vals[1].(Vector) + + for i := 0; i < len(y); i++ { + enh.Out = append(enh.Out, Sample{ + Point: Point{V: math.Atan2(y[i].V, x[i].V)}, + }) + } + return enh.Out +} + +// === rad(Vector parser.ValueTypeVector) Vector === +func funcRad(vals []parser.Value, args parser.Expressions, enh *EvalNodeHelper) Vector { + return simpleFunc(vals, enh, func(v float64) float64 { + return v * (math.Pi / 180) + }) +} + +// === deg(Vector parser.ValueTypeVector) Vector === +func funcDeg(vals []parser.Value, args parser.Expressions, enh *EvalNodeHelper) Vector { + return simpleFunc(vals, enh, func(v float64) float64 { + return v * 180 / math.Pi + }) +} + +// === pi(Vector parser.ValueTypeVector) Vector === +func funcPi(vals []parser.Value, args parser.Expressions, enh *EvalNodeHelper) Vector { + return Vector{Sample{Point: Point{ + V: math.Pi, + }}} +} + // === sgn(Vector parser.ValueTypeVector) Vector === func funcSgn(vals []parser.Value, args parser.Expressions, enh *EvalNodeHelper) Vector { return simpleFunc(vals, enh, func(v float64) float64 { @@ -935,16 +999,22 @@ var FunctionCalls = map[string]FunctionCall{ "abs": funcAbs, "absent": funcAbsent, "absent_over_time": funcAbsentOverTime, + "acos": funcAcos, + "asin": funcAsin, + "atan": funcAtan, + "atan2": funcAtan2, "avg_over_time": funcAvgOverTime, "ceil": funcCeil, "changes": funcChanges, "clamp": funcClamp, "clamp_max": funcClampMax, "clamp_min": funcClampMin, + "cos": funcCos, "count_over_time": funcCountOverTime, "days_in_month": funcDaysInMonth, "day_of_month": funcDayOfMonth, "day_of_week": funcDayOfWeek, + "deg": funcDeg, "delta": funcDelta, "deriv": funcDeriv, "exp": funcExp, @@ -965,20 +1035,24 @@ var FunctionCalls = map[string]FunctionCall{ "min_over_time": funcMinOverTime, "minute": funcMinute, "month": funcMonth, + "pi": funcPi, "predict_linear": funcPredictLinear, "present_over_time": funcPresentOverTime, "quantile_over_time": funcQuantileOverTime, + "rad": funcRad, "rate": funcRate, "resets": funcResets, "round": funcRound, "scalar": funcScalar, "sgn": funcSgn, + "sin": funcSin, "sort": funcSort, "sort_desc": funcSortDesc, "sqrt": funcSqrt, "stddev_over_time": funcStddevOverTime, "stdvar_over_time": funcStdvarOverTime, "sum_over_time": funcSumOverTime, + "tan": funcTan, "time": funcTime, "timestamp": funcTimestamp, "vector": funcVector, diff --git a/promql/parser/functions.go b/promql/parser/functions.go index da5d279f31..b454f93f89 100644 --- a/promql/parser/functions.go +++ b/promql/parser/functions.go @@ -39,9 +39,24 @@ var Functions = map[string]*Function{ ArgTypes: []ValueType{ValueTypeMatrix}, ReturnType: ValueTypeVector, }, - "present_over_time": { - Name: "present_over_time", - ArgTypes: []ValueType{ValueTypeMatrix}, + "acos": { + Name: "acos", + ArgTypes: []ValueType{ValueTypeVector}, + ReturnType: ValueTypeVector, + }, + "asin": { + Name: "asin", + ArgTypes: []ValueType{ValueTypeVector}, + ReturnType: ValueTypeVector, + }, + "atan": { + Name: "atan", + ArgTypes: []ValueType{ValueTypeVector}, + ReturnType: ValueTypeVector, + }, + "atan2": { + Name: "atan2", + ArgTypes: []ValueType{ValueTypeVector, ValueTypeVector}, ReturnType: ValueTypeVector, }, "avg_over_time": { @@ -74,6 +89,11 @@ var Functions = map[string]*Function{ ArgTypes: []ValueType{ValueTypeVector, ValueTypeScalar}, ReturnType: ValueTypeVector, }, + "cos": { + Name: "cos", + ArgTypes: []ValueType{ValueTypeVector}, + ReturnType: ValueTypeVector, + }, "count_over_time": { Name: "count_over_time", ArgTypes: []ValueType{ValueTypeMatrix}, @@ -97,6 +117,11 @@ var Functions = map[string]*Function{ Variadic: 1, ReturnType: ValueTypeVector, }, + "deg": { + Name: "deg", + ArgTypes: []ValueType{ValueTypeVector}, + ReturnType: ValueTypeVector, + }, "delta": { Name: "delta", ArgTypes: []ValueType{ValueTypeMatrix}, @@ -201,16 +226,32 @@ var Functions = map[string]*Function{ Variadic: 1, ReturnType: ValueTypeVector, }, + "pi": { + Name: "pi", + ArgTypes: []ValueType{}, + Variadic: 1, + ReturnType: ValueTypeVector, + }, "predict_linear": { Name: "predict_linear", ArgTypes: []ValueType{ValueTypeMatrix, ValueTypeScalar}, ReturnType: ValueTypeVector, }, + "present_over_time": { + Name: "present_over_time", + ArgTypes: []ValueType{ValueTypeMatrix}, + ReturnType: ValueTypeVector, + }, "quantile_over_time": { Name: "quantile_over_time", ArgTypes: []ValueType{ValueTypeScalar, ValueTypeMatrix}, ReturnType: ValueTypeVector, }, + "rad": { + Name: "rad", + ArgTypes: []ValueType{ValueTypeVector}, + ReturnType: ValueTypeVector, + }, "rate": { Name: "rate", ArgTypes: []ValueType{ValueTypeMatrix}, @@ -237,6 +278,11 @@ var Functions = map[string]*Function{ ArgTypes: []ValueType{ValueTypeVector}, ReturnType: ValueTypeVector, }, + "sin": { + Name: "sin", + ArgTypes: []ValueType{ValueTypeVector}, + ReturnType: ValueTypeVector, + }, "sort": { Name: "sort", ArgTypes: []ValueType{ValueTypeVector}, @@ -267,6 +313,11 @@ var Functions = map[string]*Function{ ArgTypes: []ValueType{ValueTypeMatrix}, ReturnType: ValueTypeVector, }, + "tan": { + Name: "tan", + ArgTypes: []ValueType{ValueTypeVector}, + ReturnType: ValueTypeVector, + }, "time": { Name: "time", ArgTypes: []ValueType{}, From 814cd5844dd5fe835732415fef237fac69223ef1 Mon Sep 17 00:00:00 2001 From: Levi Harrison Date: Mon, 23 Aug 2021 20:14:48 -0400 Subject: [PATCH 02/17] Added tests Signed-off-by: Levi Harrison --- promql/testdata/functions.test | 142 +++++++++++++++++++++++++++++---- 1 file changed, 125 insertions(+), 17 deletions(-) diff --git a/promql/testdata/functions.test b/promql/testdata/functions.test index b216c42c7b..032ba54051 100644 --- a/promql/testdata/functions.test +++ b/promql/testdata/functions.test @@ -961,65 +961,173 @@ eval instant at 10m present_over_time({job="ingress"}[4m]) clear -# Testing exp() sqrt() log2() log10() ln() +# Testing exp() sqrt() log2() log10() ln() sin() cos() tan() asin() acos() atan() atan2() deg() rad() pi() load 5m - exp_root_log{l="x"} 10 - exp_root_log{l="y"} 20 + exp_root_log_trig{l="x"} 10 + exp_root_log_trig{l="y"} 20 -eval instant at 5m exp(exp_root_log) +eval instant at 5m exp(exp_root_log_trig) {l="x"} 22026.465794806718 {l="y"} 485165195.4097903 -eval instant at 5m exp(exp_root_log - 10) +eval instant at 5m exp(exp_root_log_trig - 10) {l="y"} 22026.465794806718 {l="x"} 1 -eval instant at 5m exp(exp_root_log - 20) +eval instant at 5m exp(exp_root_log_trig - 20) {l="x"} 4.5399929762484854e-05 {l="y"} 1 -eval instant at 5m ln(exp_root_log) +eval instant at 5m ln(exp_root_log_trig) {l="x"} 2.302585092994046 {l="y"} 2.995732273553991 -eval instant at 5m ln(exp_root_log - 10) +eval instant at 5m ln(exp_root_log_trig - 10) {l="y"} 2.302585092994046 {l="x"} -Inf -eval instant at 5m ln(exp_root_log - 20) +eval instant at 5m ln(exp_root_log_trig - 20) {l="y"} -Inf {l="x"} NaN -eval instant at 5m exp(ln(exp_root_log)) +eval instant at 5m exp(ln(exp_root_log_trig)) {l="y"} 20 {l="x"} 10 -eval instant at 5m sqrt(exp_root_log) +eval instant at 5m sqrt(exp_root_log_trig) {l="x"} 3.1622776601683795 {l="y"} 4.47213595499958 -eval instant at 5m log2(exp_root_log) +eval instant at 5m log2(exp_root_log_trig) {l="x"} 3.3219280948873626 {l="y"} 4.321928094887363 -eval instant at 5m log2(exp_root_log - 10) +eval instant at 5m log2(exp_root_log_trig - 10) {l="y"} 3.3219280948873626 {l="x"} -Inf -eval instant at 5m log2(exp_root_log - 20) +eval instant at 5m log2(exp_root_log_trig - 20) {l="x"} NaN {l="y"} -Inf -eval instant at 5m log10(exp_root_log) +eval instant at 5m log10(exp_root_log_trig) {l="x"} 1 {l="y"} 1.301029995663981 -eval instant at 5m log10(exp_root_log - 10) +eval instant at 5m log10(exp_root_log_trig - 10) {l="y"} 1 {l="x"} -Inf -eval instant at 5m log10(exp_root_log - 20) +eval instant at 5m log10(exp_root_log_trig - 20) {l="x"} NaN {l="y"} -Inf +eval instant at 5m sin(exp_root_log_trig) + {l="x"} -0.5440211108893699 + {l="y"} 0.9129452507276277 + +eval instant at 5m sin(exp_root_log_trig - 10) + {l="y"} -0.5440211108893699 + {l="x"} 0 + +eval instant at 5m sin(exp_root_log_trig - 20) + {l="x"} 0.5440211108893699 + {l="y"} 0 + +eval instant at 5m cos(exp_root_log_trig) + {l="x"} -0.8390715290764524 + {l="y"} 0.40808206181339196 + +eval instant at 5m cos(exp_root_log_trig - 10) + {l="y"} -0.8390715290764524 + {l="x"} 1 + +eval instant at 5m cos(exp_root_log_trig - 20) + {l="x"} -0.8390715290764524 + {l="y"} 1 + +eval instant at 5m tan(exp_root_log_trig) + {l="x"} 0.6483608274590867 + {l="y"} 2.2371609442247427 + +eval instant at 5m tan(exp_root_log_trig - 10) + {l="y"} 0.6483608274590867 + {l="x"} 0 + +eval instant at 5m tan(exp_root_log_trig - 20) + {l="x"} -0.6483608274590867 + {l="y"} 0 + +eval instant at 5m asin(exp_root_log_trig) + {l="x"} NaN + {l="y"} NaN + +eval instant at 5m asin(exp_root_log_trig - 10) + {l="x"} 0 + {l="y"} NaN + +eval instant at 5m asin(exp_root_log_trig - 20) + {l="x"} NaN + {l="y"} 0 + +eval instant at 5m acos(exp_root_log_trig) + {l="x"} NaN + {l="y"} NaN + +eval instant at 5m acos(exp_root_log_trig - 10) + {l="x"} 1.5707963267948966 + {l="y"} NaN + +eval instant at 5m acos(exp_root_log_trig - 20) + {l="x"} NaN + {l="y"} 1.5707963267948966 + +eval instant at 5m atan(exp_root_log_trig) + {l="x"} 1.4711276743037345 + {l="y"} 1.5208379310729538 + +eval instant at 5m atan(exp_root_log_trig - 10) + {l="x"} 0 + {l="y"} 1.4711276743037345 + +eval instant at 5m atan(exp_root_log_trig - 20) + {l="x"} -1.4711276743037345 + {l="y"} 0 + +eval instant at 5m atan2(exp_root_log_trig{l="y"}, exp_root_log_trig{l="x"}) + {} 1.1071487177940904 + +eval instant at 5m atan2(exp_root_log_trig{l="y"} - 10, exp_root_log_trig{l="x"} - 10) + {} 1.5707963267948966 + +eval instant at 5m atan2(exp_root_log_trig{l="y"} - 20, exp_root_log_trig{l="x"} - 20) + {} 3.141592653589793 + +eval instant at 5m rad(exp_root_log_trig) + {l="x"} 0.17453292519943295 + {l="y"} 0.3490658503988659 + +eval instant at 5m rad(exp_root_log_trig - 10) + {l="x"} 0 + {l="y"} 0.17453292519943295 + +eval instant at 5m rad(exp_root_log_trig - 20) + {l="x"} -0.17453292519943295 + {l="y"} 0 + +eval instant at 5m deg(exp_root_log_trig) + {l="x"} 572.9577951308232 + {l="y"} 1145.9155902616465 + +eval instant at 5m deg(exp_root_log_trig - 10) + {l="x"} 0 + {l="y"} 572.9577951308232 + +eval instant at 5m deg(exp_root_log_trig - 20) + {l="x"} -572.9577951308232 + {l="y"} 0 + clear + +eval instant at 0s pi() + {} 3.141592653589793 From e5a44964ff1b6d4efd3b4ad747541d6ec3b33cc5 Mon Sep 17 00:00:00 2001 From: Levi Harrison Date: Mon, 23 Aug 2021 20:15:32 -0400 Subject: [PATCH 03/17] Added docs Signed-off-by: Levi Harrison --- docs/querying/functions.md | 42 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/docs/querying/functions.md b/docs/querying/functions.md index 079a1e320d..ad7d25f20d 100644 --- a/docs/querying/functions.md +++ b/docs/querying/functions.md @@ -434,3 +434,45 @@ over time and return an instant vector with per-series aggregation results: Note that all values in the specified interval have the same weight in the aggregation even if the values are not equally spaced throughout the interval. + +## Trigonometric Functions + +- `acos(v instant-vector)`: calculates the arccosine, in radians, of all elements in `v`. Special cases are: + - `acos(x) = NaN if x < -1 or x > 1` +- `asin(v instant-vector)`: calculates the arcsine, in radians, of all elements in `v`. Special cases are: + - `asin(±0) = ±0` +- `atan(v instant-vector)`: calculates the arctangent, in radians, of all elements in `v`. Special cases are: + - `atan(±0) = ±0` + - `atan(±Inf) = ±Pi/2` +- `atan2(y, x instant-vector)`: calculates the arctangent of `y`/`x` for all elements, in radians, using the signs of the two to determine the quadrant of the result ([from the package](https://pkg.go.dev/math#Atan2)). Special cases are: + - `atan2(y, NaN) = NaN` + - `atan2(NaN, x) = NaN` + - `atan2(+0, x>=0) = +0` + - `atan2(-0, x>=0) = -0` + - `atan2(+0, x<=-0) = +Pi` + - `atan2(-0, x<=-0) = -Pi` + - `atan2(y>0, 0) = +Pi/2` + - `atan2(y<0, 0) = -Pi/2` + - `atan2(+Inf, +Inf) = +Pi/4` + - `atan2(-Inf, +Inf) = -Pi/4` + - `atan2(+Inf, -Inf) = 3Pi/4` + - `atan2(-Inf, -Inf) = -3Pi/4` + - `atan2(y, +Inf) = 0` + - `atan2(y>0, -Inf) = +Pi` + - `atan2(y<0, -Inf) = -Pi` + - `atan2(+Inf, x) = +Pi/2` + - `atan2(-Inf, x) = -Pi/2` +- `cos(v instant-vector)`: calculates the cosine, in radians, of all elements in `v`. Special cases are: + - `cos(±Inf) = NaN` + - `cos(NaN) = NaN` +- `deg(v instant-vector)`: converts radians to degrees for all elements in `v`. +- `pi()`: returns the first 16 digits of Pi. +- `rad(v instant-vector)`: converts degrees to radians for all elements in `v`. +- `sin(v instant-vector)`: calculates the sine, in radians, of all elements in `v`. Special cases are: + - `sin(±0) = ±0` + - `sin(±Inf) = NaN` + - `Sin(NaN) = NaN` +- `tan(v instant-vector)`: calculates the tangent, in radians, of all elements in `v`. Special cases are: + - `tan(±0) = ±0` + - `tan(±Inf) = NaN` + - `tan(NaN) = NaN` \ No newline at end of file From d5ecdc4597818919793491d44e45488a55eb3224 Mon Sep 17 00:00:00 2001 From: Levi Harrison Date: Tue, 24 Aug 2021 06:58:17 -0400 Subject: [PATCH 04/17] Remove variadic Signed-off-by: Levi Harrison --- promql/parser/functions.go | 1 - 1 file changed, 1 deletion(-) diff --git a/promql/parser/functions.go b/promql/parser/functions.go index b454f93f89..3fe8d22aa6 100644 --- a/promql/parser/functions.go +++ b/promql/parser/functions.go @@ -229,7 +229,6 @@ var Functions = map[string]*Function{ "pi": { Name: "pi", ArgTypes: []ValueType{}, - Variadic: 1, ReturnType: ValueTypeVector, }, "predict_linear": { From f1d94cc5f6e16a3cdeac13a5310e488a4974b7dc Mon Sep 17 00:00:00 2001 From: Levi Harrison Date: Tue, 24 Aug 2021 07:28:01 -0400 Subject: [PATCH 05/17] Split and shortened tests Signed-off-by: Levi Harrison --- promql/testdata/functions.test | 142 ++++------------------------ promql/testdata/trig_functions.test | 71 ++++++++++++++ 2 files changed, 88 insertions(+), 125 deletions(-) create mode 100644 promql/testdata/trig_functions.test diff --git a/promql/testdata/functions.test b/promql/testdata/functions.test index 032ba54051..b216c42c7b 100644 --- a/promql/testdata/functions.test +++ b/promql/testdata/functions.test @@ -961,173 +961,65 @@ eval instant at 10m present_over_time({job="ingress"}[4m]) clear -# Testing exp() sqrt() log2() log10() ln() sin() cos() tan() asin() acos() atan() atan2() deg() rad() pi() +# Testing exp() sqrt() log2() log10() ln() load 5m - exp_root_log_trig{l="x"} 10 - exp_root_log_trig{l="y"} 20 + exp_root_log{l="x"} 10 + exp_root_log{l="y"} 20 -eval instant at 5m exp(exp_root_log_trig) +eval instant at 5m exp(exp_root_log) {l="x"} 22026.465794806718 {l="y"} 485165195.4097903 -eval instant at 5m exp(exp_root_log_trig - 10) +eval instant at 5m exp(exp_root_log - 10) {l="y"} 22026.465794806718 {l="x"} 1 -eval instant at 5m exp(exp_root_log_trig - 20) +eval instant at 5m exp(exp_root_log - 20) {l="x"} 4.5399929762484854e-05 {l="y"} 1 -eval instant at 5m ln(exp_root_log_trig) +eval instant at 5m ln(exp_root_log) {l="x"} 2.302585092994046 {l="y"} 2.995732273553991 -eval instant at 5m ln(exp_root_log_trig - 10) +eval instant at 5m ln(exp_root_log - 10) {l="y"} 2.302585092994046 {l="x"} -Inf -eval instant at 5m ln(exp_root_log_trig - 20) +eval instant at 5m ln(exp_root_log - 20) {l="y"} -Inf {l="x"} NaN -eval instant at 5m exp(ln(exp_root_log_trig)) +eval instant at 5m exp(ln(exp_root_log)) {l="y"} 20 {l="x"} 10 -eval instant at 5m sqrt(exp_root_log_trig) +eval instant at 5m sqrt(exp_root_log) {l="x"} 3.1622776601683795 {l="y"} 4.47213595499958 -eval instant at 5m log2(exp_root_log_trig) +eval instant at 5m log2(exp_root_log) {l="x"} 3.3219280948873626 {l="y"} 4.321928094887363 -eval instant at 5m log2(exp_root_log_trig - 10) +eval instant at 5m log2(exp_root_log - 10) {l="y"} 3.3219280948873626 {l="x"} -Inf -eval instant at 5m log2(exp_root_log_trig - 20) +eval instant at 5m log2(exp_root_log - 20) {l="x"} NaN {l="y"} -Inf -eval instant at 5m log10(exp_root_log_trig) +eval instant at 5m log10(exp_root_log) {l="x"} 1 {l="y"} 1.301029995663981 -eval instant at 5m log10(exp_root_log_trig - 10) +eval instant at 5m log10(exp_root_log - 10) {l="y"} 1 {l="x"} -Inf -eval instant at 5m log10(exp_root_log_trig - 20) +eval instant at 5m log10(exp_root_log - 20) {l="x"} NaN {l="y"} -Inf -eval instant at 5m sin(exp_root_log_trig) - {l="x"} -0.5440211108893699 - {l="y"} 0.9129452507276277 - -eval instant at 5m sin(exp_root_log_trig - 10) - {l="y"} -0.5440211108893699 - {l="x"} 0 - -eval instant at 5m sin(exp_root_log_trig - 20) - {l="x"} 0.5440211108893699 - {l="y"} 0 - -eval instant at 5m cos(exp_root_log_trig) - {l="x"} -0.8390715290764524 - {l="y"} 0.40808206181339196 - -eval instant at 5m cos(exp_root_log_trig - 10) - {l="y"} -0.8390715290764524 - {l="x"} 1 - -eval instant at 5m cos(exp_root_log_trig - 20) - {l="x"} -0.8390715290764524 - {l="y"} 1 - -eval instant at 5m tan(exp_root_log_trig) - {l="x"} 0.6483608274590867 - {l="y"} 2.2371609442247427 - -eval instant at 5m tan(exp_root_log_trig - 10) - {l="y"} 0.6483608274590867 - {l="x"} 0 - -eval instant at 5m tan(exp_root_log_trig - 20) - {l="x"} -0.6483608274590867 - {l="y"} 0 - -eval instant at 5m asin(exp_root_log_trig) - {l="x"} NaN - {l="y"} NaN - -eval instant at 5m asin(exp_root_log_trig - 10) - {l="x"} 0 - {l="y"} NaN - -eval instant at 5m asin(exp_root_log_trig - 20) - {l="x"} NaN - {l="y"} 0 - -eval instant at 5m acos(exp_root_log_trig) - {l="x"} NaN - {l="y"} NaN - -eval instant at 5m acos(exp_root_log_trig - 10) - {l="x"} 1.5707963267948966 - {l="y"} NaN - -eval instant at 5m acos(exp_root_log_trig - 20) - {l="x"} NaN - {l="y"} 1.5707963267948966 - -eval instant at 5m atan(exp_root_log_trig) - {l="x"} 1.4711276743037345 - {l="y"} 1.5208379310729538 - -eval instant at 5m atan(exp_root_log_trig - 10) - {l="x"} 0 - {l="y"} 1.4711276743037345 - -eval instant at 5m atan(exp_root_log_trig - 20) - {l="x"} -1.4711276743037345 - {l="y"} 0 - -eval instant at 5m atan2(exp_root_log_trig{l="y"}, exp_root_log_trig{l="x"}) - {} 1.1071487177940904 - -eval instant at 5m atan2(exp_root_log_trig{l="y"} - 10, exp_root_log_trig{l="x"} - 10) - {} 1.5707963267948966 - -eval instant at 5m atan2(exp_root_log_trig{l="y"} - 20, exp_root_log_trig{l="x"} - 20) - {} 3.141592653589793 - -eval instant at 5m rad(exp_root_log_trig) - {l="x"} 0.17453292519943295 - {l="y"} 0.3490658503988659 - -eval instant at 5m rad(exp_root_log_trig - 10) - {l="x"} 0 - {l="y"} 0.17453292519943295 - -eval instant at 5m rad(exp_root_log_trig - 20) - {l="x"} -0.17453292519943295 - {l="y"} 0 - -eval instant at 5m deg(exp_root_log_trig) - {l="x"} 572.9577951308232 - {l="y"} 1145.9155902616465 - -eval instant at 5m deg(exp_root_log_trig - 10) - {l="x"} 0 - {l="y"} 572.9577951308232 - -eval instant at 5m deg(exp_root_log_trig - 20) - {l="x"} -572.9577951308232 - {l="y"} 0 - clear - -eval instant at 0s pi() - {} 3.141592653589793 diff --git a/promql/testdata/trig_functions.test b/promql/testdata/trig_functions.test new file mode 100644 index 0000000000..fda1b29dd4 --- /dev/null +++ b/promql/testdata/trig_functions.test @@ -0,0 +1,71 @@ +# Testing sin() cos() tan() asin() acos() atan() rad() deg() pi(). + +load 5m + trig{l="x"} 10 + trig{l="y"} 20 + trig{l="NaN"} NaN + +eval instant at 5m sin(trig) + {l="x"} -0.5440211108893699 + {l="y"} 0.9129452507276277 + {l="NaN"} NaN + +eval instant at 5m cos(trig) + {l="x"} -0.8390715290764524 + {l="y"} 0.40808206181339196 + {l="NaN"} NaN + +eval instant at 5m tan(trig) + {l="x"} 0.6483608274590867 + {l="y"} 2.2371609442247427 + {l="NaN"} NaN + +eval instant at 5m asin(trig - 10.1) + {l="x"} -0.10016742116155944 + {l="y"} NaN + {l="NaN"} NaN + +eval instant at 5m acos(trig - 10.1) + {l="x"} 1.670963747956456 + {l="y"} NaN + {l="NaN"} NaN + +eval instant at 5m atan(trig) + {l="x"} 1.4711276743037345 + {l="y"} 1.5208379310729538 + {l="NaN"} NaN + +eval instant at 5m rad(trig) + {l="x"} 0.17453292519943295 + {l="y"} 0.3490658503988659 + {l="NaN"} NaN + +eval instant at 5m rad(trig - 10) + {l="x"} 0 + {l="y"} 0.17453292519943295 + {l="NaN"} NaN + +eval instant at 5m rad(trig - 20) + {l="x"} -0.17453292519943295 + {l="y"} 0 + {l="NaN"} NaN + +eval instant at 5m deg(trig) + {l="x"} 572.9577951308232 + {l="y"} 1145.9155902616465 + {l="NaN"} NaN + +eval instant at 5m deg(trig - 10) + {l="x"} 0 + {l="y"} 572.9577951308232 + {l="NaN"} NaN + +eval instant at 5m deg(trig - 20) + {l="x"} -572.9577951308232 + {l="y"} 0 + {l="NaN"} NaN + +clear + +eval instant at 0s pi() + {} 3.141592653589793 From 9fc7ba33aa57c1bd46a795370261cd6c8aababf4 Mon Sep 17 00:00:00 2001 From: Levi Harrison Date: Tue, 24 Aug 2021 07:28:22 -0400 Subject: [PATCH 06/17] Remove `atan2()` Signed-off-by: Levi Harrison --- promql/functions.go | 14 -------------- promql/parser/functions.go | 5 ----- 2 files changed, 19 deletions(-) diff --git a/promql/functions.go b/promql/functions.go index 746dd3fd58..31f359ce3c 100644 --- a/promql/functions.go +++ b/promql/functions.go @@ -600,19 +600,6 @@ func funcAtan(vals []parser.Value, args parser.Expressions, enh *EvalNodeHelper) return simpleFunc(vals, enh, math.Atan) } -// === atan2(Vector1, Vector2 parser.ValueTypeVector) Vector === -func funcAtan2(vals []parser.Value, args parser.Expressions, enh *EvalNodeHelper) Vector { - y := vals[0].(Vector) - x := vals[1].(Vector) - - for i := 0; i < len(y); i++ { - enh.Out = append(enh.Out, Sample{ - Point: Point{V: math.Atan2(y[i].V, x[i].V)}, - }) - } - return enh.Out -} - // === rad(Vector parser.ValueTypeVector) Vector === func funcRad(vals []parser.Value, args parser.Expressions, enh *EvalNodeHelper) Vector { return simpleFunc(vals, enh, func(v float64) float64 { @@ -1002,7 +989,6 @@ var FunctionCalls = map[string]FunctionCall{ "acos": funcAcos, "asin": funcAsin, "atan": funcAtan, - "atan2": funcAtan2, "avg_over_time": funcAvgOverTime, "ceil": funcCeil, "changes": funcChanges, diff --git a/promql/parser/functions.go b/promql/parser/functions.go index 3fe8d22aa6..11a49e2fbe 100644 --- a/promql/parser/functions.go +++ b/promql/parser/functions.go @@ -54,11 +54,6 @@ var Functions = map[string]*Function{ ArgTypes: []ValueType{ValueTypeVector}, ReturnType: ValueTypeVector, }, - "atan2": { - Name: "atan2", - ArgTypes: []ValueType{ValueTypeVector, ValueTypeVector}, - ReturnType: ValueTypeVector, - }, "avg_over_time": { Name: "avg_over_time", ArgTypes: []ValueType{ValueTypeMatrix}, From 535d8904f79b5289f918678e1b8f06b91929f7db Mon Sep 17 00:00:00 2001 From: Levi Harrison Date: Tue, 24 Aug 2021 07:28:56 -0400 Subject: [PATCH 07/17] Link to docs for special cases Signed-off-by: Levi Harrison --- docs/querying/functions.md | 42 ++++++-------------------------------- 1 file changed, 6 insertions(+), 36 deletions(-) diff --git a/docs/querying/functions.md b/docs/querying/functions.md index ad7d25f20d..df2a439e1d 100644 --- a/docs/querying/functions.md +++ b/docs/querying/functions.md @@ -437,42 +437,12 @@ aggregation even if the values are not equally spaced throughout the interval. ## Trigonometric Functions -- `acos(v instant-vector)`: calculates the arccosine, in radians, of all elements in `v`. Special cases are: - - `acos(x) = NaN if x < -1 or x > 1` -- `asin(v instant-vector)`: calculates the arcsine, in radians, of all elements in `v`. Special cases are: - - `asin(±0) = ±0` -- `atan(v instant-vector)`: calculates the arctangent, in radians, of all elements in `v`. Special cases are: - - `atan(±0) = ±0` - - `atan(±Inf) = ±Pi/2` -- `atan2(y, x instant-vector)`: calculates the arctangent of `y`/`x` for all elements, in radians, using the signs of the two to determine the quadrant of the result ([from the package](https://pkg.go.dev/math#Atan2)). Special cases are: - - `atan2(y, NaN) = NaN` - - `atan2(NaN, x) = NaN` - - `atan2(+0, x>=0) = +0` - - `atan2(-0, x>=0) = -0` - - `atan2(+0, x<=-0) = +Pi` - - `atan2(-0, x<=-0) = -Pi` - - `atan2(y>0, 0) = +Pi/2` - - `atan2(y<0, 0) = -Pi/2` - - `atan2(+Inf, +Inf) = +Pi/4` - - `atan2(-Inf, +Inf) = -Pi/4` - - `atan2(+Inf, -Inf) = 3Pi/4` - - `atan2(-Inf, -Inf) = -3Pi/4` - - `atan2(y, +Inf) = 0` - - `atan2(y>0, -Inf) = +Pi` - - `atan2(y<0, -Inf) = -Pi` - - `atan2(+Inf, x) = +Pi/2` - - `atan2(-Inf, x) = -Pi/2` -- `cos(v instant-vector)`: calculates the cosine, in radians, of all elements in `v`. Special cases are: - - `cos(±Inf) = NaN` - - `cos(NaN) = NaN` +- `acos(v instant-vector)`: calculates the arccosine, in radians, of all elements in `v` ([special cases](https://pkg.go.dev/math#Acos)). +- `asin(v instant-vector)`: calculates the arcsine, in radians, of all elements in `v` ([special cases](https://pkg.go.dev/math#Asin)). +- `atan(v instant-vector)`: calculates the arctangent, in radians, of all elements in `v` ([special cases](https://pkg.go.dev/math#Atan)). +- `cos(v instant-vector)`: calculates the cosine, in radians, of all elements in `v` ([special cases](https://pkg.go.dev/math#Cos)). - `deg(v instant-vector)`: converts radians to degrees for all elements in `v`. - `pi()`: returns the first 16 digits of Pi. - `rad(v instant-vector)`: converts degrees to radians for all elements in `v`. -- `sin(v instant-vector)`: calculates the sine, in radians, of all elements in `v`. Special cases are: - - `sin(±0) = ±0` - - `sin(±Inf) = NaN` - - `Sin(NaN) = NaN` -- `tan(v instant-vector)`: calculates the tangent, in radians, of all elements in `v`. Special cases are: - - `tan(±0) = ±0` - - `tan(±Inf) = NaN` - - `tan(NaN) = NaN` \ No newline at end of file +- `sin(v instant-vector)`: calculates the sine, in radians, of all elements in `v` ([special cases](https://pkg.go.dev/math#Sin)). +- `tan(v instant-vector)`: calculates the tangent, in radians, of all elements in `v` ([special cases](https://pkg.go.dev/math#Tan)). \ No newline at end of file From 51bb3d4a277ce82807c370631b985508d56ba8c5 Mon Sep 17 00:00:00 2001 From: Levi Harrison Date: Tue, 24 Aug 2021 08:12:49 -0400 Subject: [PATCH 08/17] Changed radian wording Signed-off-by: Levi Harrison --- docs/querying/functions.md | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/docs/querying/functions.md b/docs/querying/functions.md index df2a439e1d..8583ce3ec6 100644 --- a/docs/querying/functions.md +++ b/docs/querying/functions.md @@ -437,12 +437,17 @@ aggregation even if the values are not equally spaced throughout the interval. ## Trigonometric Functions -- `acos(v instant-vector)`: calculates the arccosine, in radians, of all elements in `v` ([special cases](https://pkg.go.dev/math#Acos)). -- `asin(v instant-vector)`: calculates the arcsine, in radians, of all elements in `v` ([special cases](https://pkg.go.dev/math#Asin)). -- `atan(v instant-vector)`: calculates the arctangent, in radians, of all elements in `v` ([special cases](https://pkg.go.dev/math#Atan)). -- `cos(v instant-vector)`: calculates the cosine, in radians, of all elements in `v` ([special cases](https://pkg.go.dev/math#Cos)). +The trigonometric functions work in radians: + +- `acos(v instant-vector)`: calculates the arccosine of all elements in `v` ([special cases](https://pkg.go.dev/math#Acos)). +- `asin(v instant-vector)`: calculates the arcsine of all elements in `v` ([special cases](https://pkg.go.dev/math#Asin)). +- `atan(v instant-vector)`: calculates the arctangent of all elements in `v` ([special cases](https://pkg.go.dev/math#Atan)). +- `cos(v instant-vector)`: calculates the cosine of all elements in `v` ([special cases](https://pkg.go.dev/math#Cos)). +- `sin(v instant-vector)`: calculates the sine of all elements in `v` ([special cases](https://pkg.go.dev/math#Sin)). +- `tan(v instant-vector)`: calculates the tangent of all elements in `v` ([special cases](https://pkg.go.dev/math#Tan)). + +The following are useful for converting between degrees and radians: + - `deg(v instant-vector)`: converts radians to degrees for all elements in `v`. - `pi()`: returns the first 16 digits of Pi. -- `rad(v instant-vector)`: converts degrees to radians for all elements in `v`. -- `sin(v instant-vector)`: calculates the sine, in radians, of all elements in `v` ([special cases](https://pkg.go.dev/math#Sin)). -- `tan(v instant-vector)`: calculates the tangent, in radians, of all elements in `v` ([special cases](https://pkg.go.dev/math#Tan)). \ No newline at end of file +- `rad(v instant-vector)`: converts degrees to radians for all elements in `v`. \ No newline at end of file From ecc29d38b83245ff1b38c2bfd53e8d6f45c247c8 Mon Sep 17 00:00:00 2001 From: Levi Harrison Date: Tue, 24 Aug 2021 08:41:46 -0400 Subject: [PATCH 09/17] Fixed `pi` definition Signed-off-by: Levi Harrison --- promql/parser/functions.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/promql/parser/functions.go b/promql/parser/functions.go index 11a49e2fbe..a12865a30a 100644 --- a/promql/parser/functions.go +++ b/promql/parser/functions.go @@ -224,7 +224,7 @@ var Functions = map[string]*Function{ "pi": { Name: "pi", ArgTypes: []ValueType{}, - ReturnType: ValueTypeVector, + ReturnType: ValueTypeScalar, }, "predict_linear": { Name: "predict_linear", From a8ad569db899f27256a66bb2c5ef0894b4b0a2b1 Mon Sep 17 00:00:00 2001 From: Levi Harrison Date: Tue, 24 Aug 2021 10:25:29 -0400 Subject: [PATCH 10/17] Change spaces to tabs Signed-off-by: Levi Harrison --- promql/testdata/trig_functions.test | 36 ++++++++++++++--------------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/promql/testdata/trig_functions.test b/promql/testdata/trig_functions.test index fda1b29dd4..2db4e5deb6 100644 --- a/promql/testdata/trig_functions.test +++ b/promql/testdata/trig_functions.test @@ -21,48 +21,48 @@ eval instant at 5m tan(trig) {l="NaN"} NaN eval instant at 5m asin(trig - 10.1) - {l="x"} -0.10016742116155944 - {l="y"} NaN + {l="x"} -0.10016742116155944 + {l="y"} NaN {l="NaN"} NaN eval instant at 5m acos(trig - 10.1) - {l="x"} 1.670963747956456 - {l="y"} NaN + {l="x"} 1.670963747956456 + {l="y"} NaN {l="NaN"} NaN eval instant at 5m atan(trig) - {l="x"} 1.4711276743037345 - {l="y"} 1.5208379310729538 + {l="x"} 1.4711276743037345 + {l="y"} 1.5208379310729538 {l="NaN"} NaN eval instant at 5m rad(trig) - {l="x"} 0.17453292519943295 - {l="y"} 0.3490658503988659 + {l="x"} 0.17453292519943295 + {l="y"} 0.3490658503988659 {l="NaN"} NaN eval instant at 5m rad(trig - 10) - {l="x"} 0 - {l="y"} 0.17453292519943295 + {l="x"} 0 + {l="y"} 0.17453292519943295 {l="NaN"} NaN eval instant at 5m rad(trig - 20) - {l="x"} -0.17453292519943295 - {l="y"} 0 + {l="x"} -0.17453292519943295 + {l="y"} 0 {l="NaN"} NaN eval instant at 5m deg(trig) - {l="x"} 572.9577951308232 - {l="y"} 1145.9155902616465 + {l="x"} 572.9577951308232 + {l="y"} 1145.9155902616465 {l="NaN"} NaN eval instant at 5m deg(trig - 10) - {l="x"} 0 - {l="y"} 572.9577951308232 + {l="x"} 0 + {l="y"} 572.9577951308232 {l="NaN"} NaN eval instant at 5m deg(trig - 20) - {l="x"} -572.9577951308232 - {l="y"} 0 + {l="x"} -572.9577951308232 + {l="y"} 0 {l="NaN"} NaN clear From 53d88fd14751ed8b05a67329070f17a30db4f3aa Mon Sep 17 00:00:00 2001 From: Levi Harrison Date: Tue, 24 Aug 2021 10:54:52 -0400 Subject: [PATCH 11/17] Added hyperbolic trig functions Signed-off-by: Levi Harrison --- docs/querying/functions.md | 3 +++ promql/functions.go | 18 ++++++++++++++++++ promql/parser/functions.go | 15 +++++++++++++++ promql/testdata/trig_functions.test | 19 +++++++++++++++++-- 4 files changed, 53 insertions(+), 2 deletions(-) diff --git a/docs/querying/functions.md b/docs/querying/functions.md index 8583ce3ec6..4822d331d1 100644 --- a/docs/querying/functions.md +++ b/docs/querying/functions.md @@ -443,8 +443,11 @@ The trigonometric functions work in radians: - `asin(v instant-vector)`: calculates the arcsine of all elements in `v` ([special cases](https://pkg.go.dev/math#Asin)). - `atan(v instant-vector)`: calculates the arctangent of all elements in `v` ([special cases](https://pkg.go.dev/math#Atan)). - `cos(v instant-vector)`: calculates the cosine of all elements in `v` ([special cases](https://pkg.go.dev/math#Cos)). +- `cosh(v instant-vector)`: calculates the hyperbolic cosine of all elements in `v` ([special cases](https://pkg.go.dev/math#Cosh)). - `sin(v instant-vector)`: calculates the sine of all elements in `v` ([special cases](https://pkg.go.dev/math#Sin)). +- `sinh(v instant-vector)`: calculates the hyperbolic sine of all elements in `v` ([special cases](https://pkg.go.dev/math#Sinh)). - `tan(v instant-vector)`: calculates the tangent of all elements in `v` ([special cases](https://pkg.go.dev/math#Tan)). +- `tanh(v instant-vector)`: calculates the hyperbolic tangent of all elements in `v` ([special cases](https://pkg.go.dev/math#Tanh)). The following are useful for converting between degrees and radians: diff --git a/promql/functions.go b/promql/functions.go index 31f359ce3c..690550592f 100644 --- a/promql/functions.go +++ b/promql/functions.go @@ -600,6 +600,21 @@ func funcAtan(vals []parser.Value, args parser.Expressions, enh *EvalNodeHelper) return simpleFunc(vals, enh, math.Atan) } +// == sinh(Vector parser.ValueTypeVector) Vector === +func funcSinh(vals []parser.Value, args parser.Expressions, enh *EvalNodeHelper) Vector { + return simpleFunc(vals, enh, math.Sinh) +} + +// == cosh(Vector parser.ValueTypeVector) Vector === +func funcCosh(vals []parser.Value, args parser.Expressions, enh *EvalNodeHelper) Vector { + return simpleFunc(vals, enh, math.Cosh) +} + +// == tanh(Vector parser.ValueTypeVector) Vector === +func funcTanh(vals []parser.Value, args parser.Expressions, enh *EvalNodeHelper) Vector { + return simpleFunc(vals, enh, math.Tanh) +} + // === rad(Vector parser.ValueTypeVector) Vector === func funcRad(vals []parser.Value, args parser.Expressions, enh *EvalNodeHelper) Vector { return simpleFunc(vals, enh, func(v float64) float64 { @@ -996,6 +1011,7 @@ var FunctionCalls = map[string]FunctionCall{ "clamp_max": funcClampMax, "clamp_min": funcClampMin, "cos": funcCos, + "cosh": funcCosh, "count_over_time": funcCountOverTime, "days_in_month": funcDaysInMonth, "day_of_month": funcDayOfMonth, @@ -1032,6 +1048,7 @@ var FunctionCalls = map[string]FunctionCall{ "scalar": funcScalar, "sgn": funcSgn, "sin": funcSin, + "sinh": funcSinh, "sort": funcSort, "sort_desc": funcSortDesc, "sqrt": funcSqrt, @@ -1039,6 +1056,7 @@ var FunctionCalls = map[string]FunctionCall{ "stdvar_over_time": funcStdvarOverTime, "sum_over_time": funcSumOverTime, "tan": funcTan, + "tanh": funcTanh, "time": funcTime, "timestamp": funcTimestamp, "vector": funcVector, diff --git a/promql/parser/functions.go b/promql/parser/functions.go index a12865a30a..3c281ec3dc 100644 --- a/promql/parser/functions.go +++ b/promql/parser/functions.go @@ -89,6 +89,11 @@ var Functions = map[string]*Function{ ArgTypes: []ValueType{ValueTypeVector}, ReturnType: ValueTypeVector, }, + "cosh": { + Name: "cosh", + ArgTypes: []ValueType{ValueTypeVector}, + ReturnType: ValueTypeVector, + }, "count_over_time": { Name: "count_over_time", ArgTypes: []ValueType{ValueTypeMatrix}, @@ -277,6 +282,11 @@ var Functions = map[string]*Function{ ArgTypes: []ValueType{ValueTypeVector}, ReturnType: ValueTypeVector, }, + "sinh": { + Name: "sinh", + ArgTypes: []ValueType{ValueTypeVector}, + ReturnType: ValueTypeVector, + }, "sort": { Name: "sort", ArgTypes: []ValueType{ValueTypeVector}, @@ -312,6 +322,11 @@ var Functions = map[string]*Function{ ArgTypes: []ValueType{ValueTypeVector}, ReturnType: ValueTypeVector, }, + "tanh": { + Name: "tanh", + ArgTypes: []ValueType{ValueTypeVector}, + ReturnType: ValueTypeVector, + }, "time": { Name: "time", ArgTypes: []ValueType{}, diff --git a/promql/testdata/trig_functions.test b/promql/testdata/trig_functions.test index 2db4e5deb6..56f480b4e2 100644 --- a/promql/testdata/trig_functions.test +++ b/promql/testdata/trig_functions.test @@ -1,4 +1,4 @@ -# Testing sin() cos() tan() asin() acos() atan() rad() deg() pi(). +# Testing sin() cos() tan() asin() acos() atan() sinh() cosh() tanh() rad() deg() pi(). load 5m trig{l="x"} 10 @@ -35,6 +35,21 @@ eval instant at 5m atan(trig) {l="y"} 1.5208379310729538 {l="NaN"} NaN +eval instant at 5m sinh(trig) + {l="x"} 11013.232920103324 + {l="y"} 2.4258259770489514e+08 + {l="NaN"} NaN + +eval instant at 5m cosh(trig) + {l="x"} 11013.232920103324 + {l="y"} 2.4258259770489514e+08 + {l="NaN"} NaN + +eval instant at 5m tanh(trig) + {l="x"} 0.9999999958776927 + {l="y"} 1 + {l="NaN"} NaN + eval instant at 5m rad(trig) {l="x"} 0.17453292519943295 {l="y"} 0.3490658503988659 @@ -68,4 +83,4 @@ eval instant at 5m deg(trig - 20) clear eval instant at 0s pi() - {} 3.141592653589793 + 3.141592653589793 From 9c54ee0a6e8cf3def9eb50cff14fe5617224f227 Mon Sep 17 00:00:00 2001 From: Levi Harrison Date: Tue, 24 Aug 2021 11:47:24 -0400 Subject: [PATCH 12/17] Changed function comment Signed-off-by: Levi Harrison --- promql/functions.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/promql/functions.go b/promql/functions.go index 690550592f..a093640c16 100644 --- a/promql/functions.go +++ b/promql/functions.go @@ -629,7 +629,7 @@ func funcDeg(vals []parser.Value, args parser.Expressions, enh *EvalNodeHelper) }) } -// === pi(Vector parser.ValueTypeVector) Vector === +// === pi() Scalar === func funcPi(vals []parser.Value, args parser.Expressions, enh *EvalNodeHelper) Vector { return Vector{Sample{Point: Point{ V: math.Pi, From 74faea64ddfc98aa048bed13d14a333a61129b02 Mon Sep 17 00:00:00 2001 From: Levi Harrison Date: Tue, 24 Aug 2021 11:57:02 -0400 Subject: [PATCH 13/17] Removed specification of pi digits Signed-off-by: Levi Harrison --- docs/querying/functions.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/querying/functions.md b/docs/querying/functions.md index 4822d331d1..45a559b7e3 100644 --- a/docs/querying/functions.md +++ b/docs/querying/functions.md @@ -452,5 +452,5 @@ The trigonometric functions work in radians: The following are useful for converting between degrees and radians: - `deg(v instant-vector)`: converts radians to degrees for all elements in `v`. -- `pi()`: returns the first 16 digits of Pi. +- `pi()`: returns pi. - `rad(v instant-vector)`: converts degrees to radians for all elements in `v`. \ No newline at end of file From 6faca22eec721760ba90ad4e109b5b481760e08a Mon Sep 17 00:00:00 2001 From: Levi Harrison Date: Wed, 25 Aug 2021 06:48:08 -0400 Subject: [PATCH 14/17] Add inverse hyperbolic functions Signed-off-by: Levi Harrison --- docs/querying/functions.md | 3 +++ promql/functions.go | 18 ++++++++++++++++++ promql/parser/functions.go | 15 +++++++++++++++ promql/testdata/trig_functions.test | 15 +++++++++++++++ 4 files changed, 51 insertions(+) diff --git a/docs/querying/functions.md b/docs/querying/functions.md index 45a559b7e3..33740ac4ab 100644 --- a/docs/querying/functions.md +++ b/docs/querying/functions.md @@ -440,8 +440,11 @@ aggregation even if the values are not equally spaced throughout the interval. The trigonometric functions work in radians: - `acos(v instant-vector)`: calculates the arccosine of all elements in `v` ([special cases](https://pkg.go.dev/math#Acos)). +- `acosh(v instant-vector)`: calculates the inverse hyperbolic cosine of all elements in `v` ([special cases](https://pkg.go.dev/math#Acosh)). - `asin(v instant-vector)`: calculates the arcsine of all elements in `v` ([special cases](https://pkg.go.dev/math#Asin)). +- `asinh(v instant-vector)`: calculates the inverse hyperbolic sine of all elements in `v` ([special cases](https://pkg.go.dev/math#Asinh)). - `atan(v instant-vector)`: calculates the arctangent of all elements in `v` ([special cases](https://pkg.go.dev/math#Atan)). +- `atanh(v instant-vector)`: calculates the inverse hyperbolic tangent of all elements in `v` ([special cases](https://pkg.go.dev/math#Atanh)). - `cos(v instant-vector)`: calculates the cosine of all elements in `v` ([special cases](https://pkg.go.dev/math#Cos)). - `cosh(v instant-vector)`: calculates the hyperbolic cosine of all elements in `v` ([special cases](https://pkg.go.dev/math#Cosh)). - `sin(v instant-vector)`: calculates the sine of all elements in `v` ([special cases](https://pkg.go.dev/math#Sin)). diff --git a/promql/functions.go b/promql/functions.go index a093640c16..7d1db327db 100644 --- a/promql/functions.go +++ b/promql/functions.go @@ -615,6 +615,21 @@ func funcTanh(vals []parser.Value, args parser.Expressions, enh *EvalNodeHelper) return simpleFunc(vals, enh, math.Tanh) } +// == asinh(Vector parser.ValueTypeVector) Vector === +func funcAsinh(vals []parser.Value, args parser.Expressions, enh *EvalNodeHelper) Vector { + return simpleFunc(vals, enh, math.Asinh) +} + +// == acosh(Vector parser.ValueTypeVector) Vector === +func funcAcosh(vals []parser.Value, args parser.Expressions, enh *EvalNodeHelper) Vector { + return simpleFunc(vals, enh, math.Acosh) +} + +// == atanh(Vector parser.ValueTypeVector) Vector === +func funcAtanh(vals []parser.Value, args parser.Expressions, enh *EvalNodeHelper) Vector { + return simpleFunc(vals, enh, math.Atanh) +} + // === rad(Vector parser.ValueTypeVector) Vector === func funcRad(vals []parser.Value, args parser.Expressions, enh *EvalNodeHelper) Vector { return simpleFunc(vals, enh, func(v float64) float64 { @@ -1002,8 +1017,11 @@ var FunctionCalls = map[string]FunctionCall{ "absent": funcAbsent, "absent_over_time": funcAbsentOverTime, "acos": funcAcos, + "acosh": funcAcosh, "asin": funcAsin, + "asinh": funcAsinh, "atan": funcAtan, + "atanh": funcAtanh, "avg_over_time": funcAvgOverTime, "ceil": funcCeil, "changes": funcChanges, diff --git a/promql/parser/functions.go b/promql/parser/functions.go index 3c281ec3dc..c4bc5ddb8d 100644 --- a/promql/parser/functions.go +++ b/promql/parser/functions.go @@ -44,16 +44,31 @@ var Functions = map[string]*Function{ ArgTypes: []ValueType{ValueTypeVector}, ReturnType: ValueTypeVector, }, + "acosh": { + Name: "acosh", + ArgTypes: []ValueType{ValueTypeVector}, + ReturnType: ValueTypeVector, + }, "asin": { Name: "asin", ArgTypes: []ValueType{ValueTypeVector}, ReturnType: ValueTypeVector, }, + "asinh": { + Name: "asinh", + ArgTypes: []ValueType{ValueTypeVector}, + ReturnType: ValueTypeVector, + }, "atan": { Name: "atan", ArgTypes: []ValueType{ValueTypeVector}, ReturnType: ValueTypeVector, }, + "atanh": { + Name: "atanh", + ArgTypes: []ValueType{ValueTypeVector}, + ReturnType: ValueTypeVector, + }, "avg_over_time": { Name: "avg_over_time", ArgTypes: []ValueType{ValueTypeMatrix}, diff --git a/promql/testdata/trig_functions.test b/promql/testdata/trig_functions.test index 56f480b4e2..fa5f94651b 100644 --- a/promql/testdata/trig_functions.test +++ b/promql/testdata/trig_functions.test @@ -50,6 +50,21 @@ eval instant at 5m tanh(trig) {l="y"} 1 {l="NaN"} NaN +eval instant at 5m asinh(trig) + {l="x"} 2.99822295029797 + {l="y"} 3.6895038689889055 + {l="NaN"} NaN + +eval instant at 5m acosh(trig) + {l="x"} 2.993222846126381 + {l="y"} 3.6882538673612966 + {l="NaN"} NaN + +eval instant at 5m atanh(trig - 10.1) + {l="x"} -0.10033534773107522 + {l="y"} NaN + {l="NaN"} NaN + eval instant at 5m rad(trig) {l="x"} 0.17453292519943295 {l="y"} 0.3490658503988659 From 4ac4e2ca4be823963e96b3338fda5e38e566eaf0 Mon Sep 17 00:00:00 2001 From: Levi Harrison Date: Wed, 25 Aug 2021 17:18:05 -0400 Subject: [PATCH 15/17] Remove parenthesis Signed-off-by: Levi Harrison --- promql/functions.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/promql/functions.go b/promql/functions.go index 7d1db327db..50594503dc 100644 --- a/promql/functions.go +++ b/promql/functions.go @@ -633,7 +633,7 @@ func funcAtanh(vals []parser.Value, args parser.Expressions, enh *EvalNodeHelper // === rad(Vector parser.ValueTypeVector) Vector === func funcRad(vals []parser.Value, args parser.Expressions, enh *EvalNodeHelper) Vector { return simpleFunc(vals, enh, func(v float64) float64 { - return v * (math.Pi / 180) + return v * math.Pi / 180 }) } From ed220c1ae7eb8f0908b191da020483d442b10650 Mon Sep 17 00:00:00 2001 From: Levi Harrison Date: Sun, 29 Aug 2021 13:33:39 -0400 Subject: [PATCH 16/17] Add grammar Signed-off-by: Levi Harrison --- .../src/complete/promql.terms.ts | 90 +++++++++++++++ .../src/grammar/promql.grammar | 30 +++++ web/ui/module/codemirror-promql/src/promql.ts | 2 +- .../codemirror-promql/src/types/function.ts | 105 ++++++++++++++++++ 4 files changed, 226 insertions(+), 1 deletion(-) diff --git a/web/ui/module/codemirror-promql/src/complete/promql.terms.ts b/web/ui/module/codemirror-promql/src/complete/promql.terms.ts index a669e78c55..3caf235bfb 100644 --- a/web/ui/module/codemirror-promql/src/complete/promql.terms.ts +++ b/web/ui/module/codemirror-promql/src/complete/promql.terms.ts @@ -64,6 +64,42 @@ export const functionIdentifierTerms = [ info: 'Determine whether input range vector is empty', type: 'function', }, + { + label: 'acos', + detail: 'function', + info: 'Calculate the arccosine, in radians, for input series', + type: 'function', + }, + { + label: 'acosh', + detail: 'function', + info: 'Calculate the inverse hyperbolic cosine, in radians, for input series', + type: 'function', + }, + { + label: 'asin', + detail: 'function', + info: 'Calculate the arcsine, in radians, for input series', + type: 'function', + }, + { + label: 'asinh', + detail: 'function', + info: 'Calculate the inverse hyperbolic sine, in radians, for input series', + type: 'function', + }, + { + label: 'atan', + detail: 'function', + info: 'Calculate the arctangent, in radians, for input series', + type: 'function', + }, + { + label: 'atanh', + detail: 'function', + info: 'Calculate the inverse hyperbolic tangent, in radians, for input series', + type: 'function', + }, { label: 'avg_over_time', detail: 'function', @@ -100,6 +136,18 @@ export const functionIdentifierTerms = [ info: 'Limit the value of input series to a minimum', type: 'function', }, + { + label: 'cos', + detail: 'function', + info: 'Calculate the cosine, in radians, for input series', + type: 'function', + }, + { + label: 'cosh', + detail: 'function', + info: 'Calculate the hyperbolic cosine, in radians, for input series', + type: 'function', + }, { label: 'count_over_time', detail: 'function', @@ -124,6 +172,12 @@ export const functionIdentifierTerms = [ info: 'Return the day of the week for provided timestamps', type: 'function', }, + { + label: 'deg', + detail: 'function', + info: 'Convert radians to degrees for input series', + type: 'function', + }, { label: 'delta', detail: 'function', @@ -244,6 +298,12 @@ export const functionIdentifierTerms = [ info: 'Return the month for provided timestamps', type: 'function', }, + { + label: 'pi', + detail: 'function', + info: 'Return pi', + type: 'function', + }, { label: 'predict_linear', detail: 'function', @@ -262,6 +322,12 @@ export const functionIdentifierTerms = [ info: 'Calculate value quantiles over time for input series', type: 'function', }, + { + label: 'rad', + detail: 'function', + info: 'Convert degrees to radians for input series', + type: 'function', + }, { label: 'rate', detail: 'function', @@ -292,6 +358,18 @@ export const functionIdentifierTerms = [ info: 'Returns the sign of the instant vector', type: 'function', }, + { + label: 'sin', + detail: 'function', + info: 'Calculate the sine, in radians, for input series', + type: 'function', + }, + { + label: 'sinh', + detail: 'function', + info: 'Calculate the hyperbolic sine, in radians, for input series', + type: 'function', + }, { label: 'sort', detail: 'function', @@ -328,6 +406,18 @@ export const functionIdentifierTerms = [ info: 'Calculate the sum over the values of input series over time', type: 'function', }, + { + label: 'tan', + detail: 'function', + info: 'Calculate the tangent, in radians, for input series', + type: 'function', + }, + { + label: 'tanh', + detail: 'function', + info: 'Calculate the hyperbolic tangent, in radians, for input series', + type: 'function', + }, { label: 'time', detail: 'function', diff --git a/web/ui/module/codemirror-promql/src/grammar/promql.grammar b/web/ui/module/codemirror-promql/src/grammar/promql.grammar index b5dac8bf7c..1cbbefa021 100644 --- a/web/ui/module/codemirror-promql/src/grammar/promql.grammar +++ b/web/ui/module/codemirror-promql/src/grammar/promql.grammar @@ -121,16 +121,25 @@ FunctionIdentifier { AbsentOverTime | Absent | Abs | + Acos | + Acosh | + Asin | + Asinh | + Atan | + Atanh | AvgOverTime | Ceil | Changes | Clamp | ClampMax | ClampMin | + Cos | + Cosh | CountOverTime | DaysInMonth | DayOfMonth | DayOfWeek | + Deg | Delta | Deriv | Exp | @@ -151,20 +160,26 @@ FunctionIdentifier { MinOverTime | Minute | Month | + Pi | PredictLinear | PresentOverTime | QuantileOverTime | + Rad | Rate | Resets | Round | Scalar | Sgn | + Sin | + Sinh | Sort | SortDesc | Sqrt | StddevOverTime | StdvarOverTime | SumOverTime | + Tan | + Tanh | Timestamp | Time | Vector | @@ -343,16 +358,25 @@ NumberLiteral { Abs { condFn<"abs"> } Absent { condFn<"absent"> } AbsentOverTime { condFn<"absent_over_time"> } + Acos { condFn<"acos"> } + Acosh { condFn<"acosh"> } + Asin { condFn<"asin"> } + Asinh { condFn<"asinh">} + Atan { condFn<"atan"> } + Atanh { condFn<"atanh">} AvgOverTime { condFn<"avg_over_time"> } Ceil { condFn<"ceil"> } Changes { condFn<"changes"> } Clamp { condFn<"clamp"> } ClampMax { condFn<"clamp_max"> } ClampMin { condFn<"clamp_min"> } + Cos { condFn<"cos">} + Cosh { condFn<"cosh">} CountOverTime { condFn<"count_over_time"> } DaysInMonth { condFn<"days_in_month"> } DayOfMonth { condFn<"day_of_month"> } DayOfWeek { condFn<"day_of_week"> } + Deg { condFn<"deg"> } Delta { condFn<"delta"> } Deriv { condFn<"deriv"> } Exp { condFn<"exp"> } @@ -373,20 +397,26 @@ NumberLiteral { MinOverTime { condFn<"min_over_time"> } Minute { condFn<"minute"> } Month { condFn<"month"> } + Pi { condFn<"pi">} PredictLinear { condFn<"predict_linear"> } PresentOverTime { condFn<"present_over_time"> } QuantileOverTime { condFn<"quantile_over_time"> } + Rad { condFn<"rad"> } Rate { condFn<"rate"> } Resets { condFn<"resets"> } Round { condFn<"round"> } Scalar { condFn<"scalar"> } Sgn { condFn<"sgn"> } + Sin { condFn<"sin">} + Sinh { condFn<"sinh"> } Sort { condFn<"sort"> } SortDesc { condFn<"sort_desc"> } Sqrt { condFn<"sqrt"> } StddevOverTime { condFn<"stddev_over_time"> } StdvarOverTime { condFn<"stdvar_over_time"> } SumOverTime { condFn<"sum_over_time"> } + Tan { condFn<"tan"> } + Tanh { condFn<"tanh">} Time { condFn<"time"> } Timestamp { condFn<"timestamp"> } Vector { condFn<"vector"> } diff --git a/web/ui/module/codemirror-promql/src/promql.ts b/web/ui/module/codemirror-promql/src/promql.ts index 01323edf96..4110c790ca 100644 --- a/web/ui/module/codemirror-promql/src/promql.ts +++ b/web/ui/module/codemirror-promql/src/promql.ts @@ -35,7 +35,7 @@ export function promQLLanguage(top: LanguageType) { StringLiteral: tags.string, NumberLiteral: tags.number, Duration: tags.number, - 'Abs Absent AbsentOverTime AvgOverTime Ceil Changes Clamp ClampMax ClampMin CountOverTime DaysInMonth DayOfMonth DayOfWeek Delta Deriv Exp Floor HistogramQuantile HoltWinters Hour Idelta Increase Irate LabelReplace LabelJoin LastOverTime Ln Log10 Log2 MaxOverTime MinOverTime Minute Month PredictLinear PresentOverTime QuantileOverTime Rate Resets Round Scalar Sgn Sort SortDesc Sqrt StddevOverTime StdvarOverTime SumOverTime Time Timestamp Vector Year': + 'Abs Absent AbsentOverTime Acos Acosh Asin Asinh Atan Atanh AvgOverTime Ceil Changes Clamp ClampMax ClampMin Cos Cosh CountOverTime DaysInMonth DayOfMonth DayOfWeek Deg Delta Deriv Exp Floor HistogramQuantile HoltWinters Hour Idelta Increase Irate LabelReplace LabelJoin LastOverTime Ln Log10 Log2 MaxOverTime MinOverTime Minute Month Pi PredictLinear PresentOverTime QuantileOverTime Rad Rate Resets Round Scalar Sgn Sin Sinh Sort SortDesc Sqrt StddevOverTime StdvarOverTime SumOverTime Tan Tanh Time Timestamp Vector Year': tags.function(tags.variableName), 'Avg Bottomk Count Count_values Group Max Min Quantile Stddev Stdvar Sum Topk': tags.operatorKeyword, 'By Without Bool On Ignoring GroupLeft GroupRight Offset Start End': tags.modifier, diff --git a/web/ui/module/codemirror-promql/src/types/function.ts b/web/ui/module/codemirror-promql/src/types/function.ts index 890ef243e8..4a2015534d 100644 --- a/web/ui/module/codemirror-promql/src/types/function.ts +++ b/web/ui/module/codemirror-promql/src/types/function.ts @@ -15,16 +15,25 @@ import { Abs, Absent, AbsentOverTime, + Acos, + Acosh, + Asin, + Asinh, + Atan, + Atanh, AvgOverTime, Ceil, Changes, Clamp, ClampMax, ClampMin, + Cos, + Cosh, CountOverTime, DayOfMonth, DayOfWeek, DaysInMonth, + Deg, Delta, Deriv, Exp, @@ -45,20 +54,26 @@ import { MinOverTime, Minute, Month, + Pi, PredictLinear, PresentOverTime, QuantileOverTime, + Rad, Rate, Resets, Round, Scalar, Sgn, + Sin, + Sinh, Sort, SortDesc, Sqrt, StddevOverTime, StdvarOverTime, SumOverTime, + Tan, + Tanh, Time, Timestamp, Vector, @@ -101,6 +116,42 @@ const promqlFunctions: { [key: number]: PromQLFunction } = { variadic: 0, returnType: ValueType.vector, }, + [Acos]: { + name: 'acos', + argTypes: [ValueType.vector], + variadic: 0, + returnType: ValueType.vector, + }, + [Acosh]: { + name: 'acosh', + argTypes: [ValueType.vector], + variadic: 0, + returnType: ValueType.vector, + }, + [Asin]: { + name: 'asin', + argTypes: [ValueType.vector], + variadic: 0, + returnType: ValueType.vector, + }, + [Asinh]: { + name: 'asinh', + argTypes: [ValueType.vector], + variadic: 0, + returnType: ValueType.vector, + }, + [Atan]: { + name: 'atan', + argTypes: [ValueType.vector], + variadic: 0, + returnType: ValueType.vector, + }, + [Atanh]: { + name: 'atanh', + argTypes: [ValueType.vector], + variadic: 0, + returnType: ValueType.vector, + }, [AvgOverTime]: { name: 'avg_over_time', argTypes: [ValueType.matrix], @@ -137,6 +188,18 @@ const promqlFunctions: { [key: number]: PromQLFunction } = { variadic: 0, returnType: ValueType.vector, }, + [Cos]: { + name: 'cos', + argTypes: [ValueType.vector], + variadic: 0, + returnType: ValueType.vector, + }, + [Cosh]: { + name: 'Cosh', + argTypes: [ValueType.vector], + variadic: 0, + returnType: ValueType.vector, + }, [CountOverTime]: { name: 'count_over_time', argTypes: [ValueType.matrix], @@ -161,6 +224,12 @@ const promqlFunctions: { [key: number]: PromQLFunction } = { variadic: 1, returnType: ValueType.vector, }, + [Deg]: { + name: 'deg', + argTypes: [ValueType.vector], + variadic: 0, + returnType: ValueType.vector, + }, [Delta]: { name: 'delta', argTypes: [ValueType.matrix], @@ -281,6 +350,12 @@ const promqlFunctions: { [key: number]: PromQLFunction } = { variadic: 1, returnType: ValueType.vector, }, + [Pi]: { + name: 'pi', + argTypes: [], + variadic: 0, + returnType: ValueType.vector, + }, [PredictLinear]: { name: 'predict_linear', argTypes: [ValueType.matrix, ValueType.scalar], @@ -299,6 +374,12 @@ const promqlFunctions: { [key: number]: PromQLFunction } = { variadic: 0, returnType: ValueType.vector, }, + [Rad]: { + name: 'rad', + argTypes: [ValueType.vector], + variadic: 0, + returnType: ValueType.vector, + }, [Rate]: { name: 'rate', argTypes: [ValueType.matrix], @@ -329,6 +410,18 @@ const promqlFunctions: { [key: number]: PromQLFunction } = { variadic: 0, returnType: ValueType.vector, }, + [Sin]: { + name: 'sin', + argTypes: [ValueType.vector], + variadic: 0, + returnType: ValueType.vector, + }, + [Sinh]: { + name: 'Sinh', + argTypes: [ValueType.vector], + variadic: 0, + returnType: ValueType.vector, + }, [Sort]: { name: 'sort', argTypes: [ValueType.vector], @@ -365,6 +458,18 @@ const promqlFunctions: { [key: number]: PromQLFunction } = { variadic: 0, returnType: ValueType.vector, }, + [Tan]: { + name: 'tan', + argTypes: [ValueType.vector], + variadic: 0, + returnType: ValueType.vector, + }, + [Tanh]: { + name: 'tanh', + argTypes: [ValueType.vector], + variadic: 0, + returnType: ValueType.vector, + }, [Time]: { name: 'time', argTypes: [], From 2c7bec758d7734960be8582a73a9771105b69112 Mon Sep 17 00:00:00 2001 From: Levi Harrison Date: Sun, 29 Aug 2021 14:10:01 -0400 Subject: [PATCH 17/17] Tabs to spaces Signed-off-by: Levi Harrison --- .../src/grammar/promql.grammar | 60 +++++++++---------- 1 file changed, 30 insertions(+), 30 deletions(-) diff --git a/web/ui/module/codemirror-promql/src/grammar/promql.grammar b/web/ui/module/codemirror-promql/src/grammar/promql.grammar index 1cbbefa021..2814a35c52 100644 --- a/web/ui/module/codemirror-promql/src/grammar/promql.grammar +++ b/web/ui/module/codemirror-promql/src/grammar/promql.grammar @@ -121,25 +121,25 @@ FunctionIdentifier { AbsentOverTime | Absent | Abs | - Acos | - Acosh | - Asin | - Asinh | - Atan | - Atanh | + Acos | + Acosh | + Asin | + Asinh | + Atan | + Atanh | AvgOverTime | Ceil | Changes | Clamp | ClampMax | ClampMin | - Cos | - Cosh | + Cos | + Cosh | CountOverTime | DaysInMonth | DayOfMonth | DayOfWeek | - Deg | + Deg | Delta | Deriv | Exp | @@ -160,26 +160,26 @@ FunctionIdentifier { MinOverTime | Minute | Month | - Pi | + Pi | PredictLinear | PresentOverTime | QuantileOverTime | - Rad | + Rad | Rate | Resets | Round | Scalar | Sgn | - Sin | - Sinh | + Sin | + Sinh | Sort | SortDesc | Sqrt | StddevOverTime | StdvarOverTime | SumOverTime | - Tan | - Tanh | + Tan | + Tanh | Timestamp | Time | Vector | @@ -358,25 +358,25 @@ NumberLiteral { Abs { condFn<"abs"> } Absent { condFn<"absent"> } AbsentOverTime { condFn<"absent_over_time"> } - Acos { condFn<"acos"> } - Acosh { condFn<"acosh"> } - Asin { condFn<"asin"> } - Asinh { condFn<"asinh">} - Atan { condFn<"atan"> } - Atanh { condFn<"atanh">} + Acos { condFn<"acos"> } + Acosh { condFn<"acosh"> } + Asin { condFn<"asin"> } + Asinh { condFn<"asinh">} + Atan { condFn<"atan"> } + Atanh { condFn<"atanh">} AvgOverTime { condFn<"avg_over_time"> } Ceil { condFn<"ceil"> } Changes { condFn<"changes"> } Clamp { condFn<"clamp"> } ClampMax { condFn<"clamp_max"> } ClampMin { condFn<"clamp_min"> } - Cos { condFn<"cos">} - Cosh { condFn<"cosh">} + Cos { condFn<"cos">} + Cosh { condFn<"cosh">} CountOverTime { condFn<"count_over_time"> } DaysInMonth { condFn<"days_in_month"> } DayOfMonth { condFn<"day_of_month"> } DayOfWeek { condFn<"day_of_week"> } - Deg { condFn<"deg"> } + Deg { condFn<"deg"> } Delta { condFn<"delta"> } Deriv { condFn<"deriv"> } Exp { condFn<"exp"> } @@ -397,26 +397,26 @@ NumberLiteral { MinOverTime { condFn<"min_over_time"> } Minute { condFn<"minute"> } Month { condFn<"month"> } - Pi { condFn<"pi">} + Pi { condFn<"pi">} PredictLinear { condFn<"predict_linear"> } PresentOverTime { condFn<"present_over_time"> } QuantileOverTime { condFn<"quantile_over_time"> } - Rad { condFn<"rad"> } + Rad { condFn<"rad"> } Rate { condFn<"rate"> } Resets { condFn<"resets"> } Round { condFn<"round"> } Scalar { condFn<"scalar"> } Sgn { condFn<"sgn"> } - Sin { condFn<"sin">} - Sinh { condFn<"sinh"> } + Sin { condFn<"sin">} + Sinh { condFn<"sinh"> } Sort { condFn<"sort"> } SortDesc { condFn<"sort_desc"> } Sqrt { condFn<"sqrt"> } StddevOverTime { condFn<"stddev_over_time"> } StdvarOverTime { condFn<"stdvar_over_time"> } SumOverTime { condFn<"sum_over_time"> } - Tan { condFn<"tan"> } - Tanh { condFn<"tanh">} + Tan { condFn<"tan"> } + Tanh { condFn<"tanh">} Time { condFn<"time"> } Timestamp { condFn<"timestamp"> } Vector { condFn<"vector"> }