app/vmselect/promql: rename sign() function to sgn() in order to be consistent with Prometheus

See https://github.com/prometheus/prometheus/pull/8457 for details.
This commit is contained in:
Aliaksandr Valialkin 2021-08-22 22:27:56 +03:00
parent 69c291353b
commit 0078486ea7
9 changed files with 13 additions and 11 deletions

View file

@ -1954,9 +1954,9 @@ func TestExecSuccess(t *testing.T) {
resultExpected := []netstorage.Result{r1, r2} resultExpected := []netstorage.Result{r1, r2}
f(q, resultExpected) f(q, resultExpected)
}) })
t.Run(`sign(time()-1400)`, func(t *testing.T) { t.Run(`sgn(time()-1400)`, func(t *testing.T) {
t.Parallel() t.Parallel()
q := `sign(time()-1400)` q := `sgn(time()-1400)`
r := netstorage.Result{ r := netstorage.Result{
MetricName: metricNameExpected, MetricName: metricNameExpected,
Values: []float64{-1, -1, 0, 1, 1, 1}, Values: []float64{-1, -1, 0, 1, 1, 1},
@ -6871,7 +6871,7 @@ func TestExecError(t *testing.T) {
f(`label_mismatch()`) f(`label_mismatch()`)
f(`round()`) f(`round()`)
f(`round(1,2,3)`) f(`round(1,2,3)`)
f(`sign()`) f(`sgn()`)
f(`scalar()`) f(`scalar()`)
f(`sort(1,2)`) f(`sort(1,2)`)
f(`sort_desc()`) f(`sort_desc()`)

View file

@ -43,6 +43,7 @@ var rollupFuncs = map[string]newRollupFunc{
"stdvar_over_time": newRollupFuncOneArg(rollupStdvar), "stdvar_over_time": newRollupFuncOneArg(rollupStdvar),
"absent_over_time": newRollupFuncOneArg(rollupAbsent), "absent_over_time": newRollupFuncOneArg(rollupAbsent),
"present_over_time": newRollupFuncOneArg(rollupPresent), "present_over_time": newRollupFuncOneArg(rollupPresent),
"last_over_time": newRollupFuncOneArg(rollupLast),
// Additional rollup funcs. // Additional rollup funcs.
"default_rollup": newRollupFuncOneArg(rollupDefault), // default rollup func "default_rollup": newRollupFuncOneArg(rollupDefault), // default rollup func
@ -50,7 +51,6 @@ var rollupFuncs = map[string]newRollupFunc{
"sum2_over_time": newRollupFuncOneArg(rollupSum2), "sum2_over_time": newRollupFuncOneArg(rollupSum2),
"geomean_over_time": newRollupFuncOneArg(rollupGeomean), "geomean_over_time": newRollupFuncOneArg(rollupGeomean),
"first_over_time": newRollupFuncOneArg(rollupFirst), "first_over_time": newRollupFuncOneArg(rollupFirst),
"last_over_time": newRollupFuncOneArg(rollupLast),
"distinct_over_time": newRollupFuncOneArg(rollupDistinct), "distinct_over_time": newRollupFuncOneArg(rollupDistinct),
"increases_over_time": newRollupFuncOneArg(rollupIncreases), "increases_over_time": newRollupFuncOneArg(rollupIncreases),
"decreases_over_time": newRollupFuncOneArg(rollupDecreases), "decreases_over_time": newRollupFuncOneArg(rollupDecreases),

View file

@ -63,7 +63,7 @@ var transformFuncs = map[string]transformFunc{
"minute": newTransformFuncDateTime(transformMinute), "minute": newTransformFuncDateTime(transformMinute),
"month": newTransformFuncDateTime(transformMonth), "month": newTransformFuncDateTime(transformMonth),
"round": transformRound, "round": transformRound,
"sign": transformSign, "sgn": transformSign,
"scalar": transformScalar, "scalar": transformScalar,
"sort": newTransformFuncSort(false), "sort": newTransformFuncSort(false),
"sort_desc": newTransformFuncSort(true), "sort_desc": newTransformFuncSort(true),

View file

@ -11,6 +11,8 @@ sort: 15
* FEATURE: vmalert: add `-disableAlertgroupLabel` command-line flag for disabling the label with alert group name. This may be needed for proper deduplication in Alertmanager. See [this issue](https://github.com/VictoriaMetrics/VictoriaMetrics/issues/1532). * FEATURE: vmalert: add `-disableAlertgroupLabel` command-line flag for disabling the label with alert group name. This may be needed for proper deduplication in Alertmanager. See [this issue](https://github.com/VictoriaMetrics/VictoriaMetrics/issues/1532).
* FEATURE: update Go builder from v1.16.7 to v1.17.0. This improves data ingestion and query performance by up to 5% according to benchmarks. See [the release post for Go1.17](https://go.dev/blog/go1.17). * FEATURE: update Go builder from v1.16.7 to v1.17.0. This improves data ingestion and query performance by up to 5% according to benchmarks. See [the release post for Go1.17](https://go.dev/blog/go1.17).
* BUGFIX: rename `sign` function to `sgn` in order to be consistent with PromQL. See [this pull request from Prometheus](https://github.com/prometheus/prometheus/pull/8457).
## [v1.64.1](https://github.com/VictoriaMetrics/VictoriaMetrics/releases/tag/v1.64.1) ## [v1.64.1](https://github.com/VictoriaMetrics/VictoriaMetrics/releases/tag/v1.64.1)

2
go.mod
View file

@ -9,7 +9,7 @@ require (
// like https://github.com/valyala/fasthttp/commit/996610f021ff45fdc98c2ce7884d5fa4e7f9199b // like https://github.com/valyala/fasthttp/commit/996610f021ff45fdc98c2ce7884d5fa4e7f9199b
github.com/VictoriaMetrics/fasthttp v1.0.16 github.com/VictoriaMetrics/fasthttp v1.0.16
github.com/VictoriaMetrics/metrics v1.17.3 github.com/VictoriaMetrics/metrics v1.17.3
github.com/VictoriaMetrics/metricsql v0.18.0 github.com/VictoriaMetrics/metricsql v0.20.0
github.com/VividCortex/ewma v1.2.0 // indirect github.com/VividCortex/ewma v1.2.0 // indirect
github.com/aws/aws-sdk-go v1.40.27 github.com/aws/aws-sdk-go v1.40.27
github.com/cespare/xxhash/v2 v2.1.1 github.com/cespare/xxhash/v2 v2.1.1

4
go.sum
View file

@ -108,8 +108,8 @@ github.com/VictoriaMetrics/fasthttp v1.0.16/go.mod h1:s9o5H4T58Kt4CTrdyJp4RorBKC
github.com/VictoriaMetrics/metrics v1.12.2/go.mod h1:Z1tSfPfngDn12bTfZSCqArT3OPY3u88J12hSoOhuiRE= github.com/VictoriaMetrics/metrics v1.12.2/go.mod h1:Z1tSfPfngDn12bTfZSCqArT3OPY3u88J12hSoOhuiRE=
github.com/VictoriaMetrics/metrics v1.17.3 h1:QPUakR6JRy8BhL2C2kOgYKLuoPDwtJQ+7iKIZSjt1A4= github.com/VictoriaMetrics/metrics v1.17.3 h1:QPUakR6JRy8BhL2C2kOgYKLuoPDwtJQ+7iKIZSjt1A4=
github.com/VictoriaMetrics/metrics v1.17.3/go.mod h1:Z1tSfPfngDn12bTfZSCqArT3OPY3u88J12hSoOhuiRE= github.com/VictoriaMetrics/metrics v1.17.3/go.mod h1:Z1tSfPfngDn12bTfZSCqArT3OPY3u88J12hSoOhuiRE=
github.com/VictoriaMetrics/metricsql v0.18.0 h1:BLNCjJPK305rfD4fjpWu7GV9snFj+zlhY8ispLB6rDs= github.com/VictoriaMetrics/metricsql v0.20.0 h1:1rL/naP4+PXdY3Hg5Oj8+Ql+NZCIHzl/OjTmOdg3+mM=
github.com/VictoriaMetrics/metricsql v0.18.0/go.mod h1:ylO7YITho/Iw6P71oEaGyHbO94bGoGtzWfLGqFhMIg8= github.com/VictoriaMetrics/metricsql v0.20.0/go.mod h1:ylO7YITho/Iw6P71oEaGyHbO94bGoGtzWfLGqFhMIg8=
github.com/VividCortex/ewma v1.1.1/go.mod h1:2Tkkvm3sRDVXaiyucHiACn4cqf7DpdyLvmxzcbUokwA= github.com/VividCortex/ewma v1.1.1/go.mod h1:2Tkkvm3sRDVXaiyucHiACn4cqf7DpdyLvmxzcbUokwA=
github.com/VividCortex/ewma v1.2.0 h1:f58SaIzcDXrSy3kWaHNvuJgJ3Nmz59Zji6XoJR/q1ow= github.com/VividCortex/ewma v1.2.0 h1:f58SaIzcDXrSy3kWaHNvuJgJ3Nmz59Zji6XoJR/q1ow=
github.com/VividCortex/ewma v1.2.0/go.mod h1:nz4BbCtbLyFDeC9SUHbtcT5644juEuWfUAUnGx7j5l4= github.com/VividCortex/ewma v1.2.0/go.mod h1:nz4BbCtbLyFDeC9SUHbtcT5644juEuWfUAUnGx7j5l4=

View file

@ -28,6 +28,7 @@ var rollupFuncs = map[string]bool{
"stdvar_over_time": true, "stdvar_over_time": true,
"absent_over_time": true, "absent_over_time": true,
"present_over_time": true, "present_over_time": true,
"last_over_time": true,
// Additional rollup funcs. // Additional rollup funcs.
"default_rollup": true, "default_rollup": true,
@ -35,7 +36,6 @@ var rollupFuncs = map[string]bool{
"sum2_over_time": true, "sum2_over_time": true,
"geomean_over_time": true, "geomean_over_time": true,
"first_over_time": true, "first_over_time": true,
"last_over_time": true,
"distinct_over_time": true, "distinct_over_time": true,
"increases_over_time": true, "increases_over_time": true,
"decreases_over_time": true, "decreases_over_time": true,

View file

@ -29,7 +29,7 @@ var transformFuncs = map[string]bool{
"month": true, "month": true,
"round": true, "round": true,
"scalar": true, "scalar": true,
"sign": true, "sgn": true,
"sort": true, "sort": true,
"sort_desc": true, "sort_desc": true,
"sqrt": true, "sqrt": true,

2
vendor/modules.txt vendored
View file

@ -21,7 +21,7 @@ github.com/VictoriaMetrics/fasthttp/stackless
# github.com/VictoriaMetrics/metrics v1.17.3 # github.com/VictoriaMetrics/metrics v1.17.3
## explicit ## explicit
github.com/VictoriaMetrics/metrics github.com/VictoriaMetrics/metrics
# github.com/VictoriaMetrics/metricsql v0.18.0 # github.com/VictoriaMetrics/metricsql v0.20.0
## explicit ## explicit
github.com/VictoriaMetrics/metricsql github.com/VictoriaMetrics/metricsql
github.com/VictoriaMetrics/metricsql/binaryop github.com/VictoriaMetrics/metricsql/binaryop