From 2a845e2acf7ae96f5e6ca35b1cba56a9d9d46713 Mon Sep 17 00:00:00 2001 From: Aliaksandr Valialkin Date: Tue, 18 Jul 2023 15:59:53 -0700 Subject: [PATCH] properly encode the right part of binary operation if it starts with `prefix` series selector --- go.mod | 2 +- go.sum | 4 ++-- vendor/github.com/VictoriaMetrics/metricsql/parser.go | 8 ++++++-- vendor/modules.txt | 2 +- 4 files changed, 10 insertions(+), 6 deletions(-) diff --git a/go.mod b/go.mod index 67966835d..5681aedba 100644 --- a/go.mod +++ b/go.mod @@ -12,7 +12,7 @@ require ( // like https://github.com/valyala/fasthttp/commit/996610f021ff45fdc98c2ce7884d5fa4e7f9199b github.com/VictoriaMetrics/fasthttp v1.2.0 github.com/VictoriaMetrics/metrics v1.24.0 - github.com/VictoriaMetrics/metricsql v0.59.0 + github.com/VictoriaMetrics/metricsql v0.59.1 github.com/aws/aws-sdk-go-v2 v1.18.1 github.com/aws/aws-sdk-go-v2/config v1.18.27 github.com/aws/aws-sdk-go-v2/feature/s3/manager v1.11.71 diff --git a/go.sum b/go.sum index 5ad405925..2e4a3f7c8 100644 --- a/go.sum +++ b/go.sum @@ -69,8 +69,8 @@ github.com/VictoriaMetrics/fasthttp v1.2.0 h1:nd9Wng4DlNtaI27WlYh5mGXCJOmee/2c2b github.com/VictoriaMetrics/fasthttp v1.2.0/go.mod h1:zv5YSmasAoSyv8sBVexfArzFDIGGTN4TfCKAtAw7IfE= github.com/VictoriaMetrics/metrics v1.24.0 h1:ILavebReOjYctAGY5QU2F9X0MYvkcrG3aEn2RKa1Zkw= github.com/VictoriaMetrics/metrics v1.24.0/go.mod h1:eFT25kvsTidQFHb6U0oa0rTrDRdz4xTYjpL8+UPohys= -github.com/VictoriaMetrics/metricsql v0.59.0 h1:0kX7hSCcFFciVEOfoJsIkmlaLJkgoP/lmAsqlJTtTgg= -github.com/VictoriaMetrics/metricsql v0.59.0/go.mod h1:k4UaP/+CjuZslIjd+kCigNG9TQmUqh5v0TP/nMEy90I= +github.com/VictoriaMetrics/metricsql v0.59.1 h1:G7FJLyYQlM9kSIK9EWDW8Dc7J0Bke3Onfle3Syr3CBs= +github.com/VictoriaMetrics/metricsql v0.59.1/go.mod h1:k4UaP/+CjuZslIjd+kCigNG9TQmUqh5v0TP/nMEy90I= github.com/VividCortex/ewma v1.2.0 h1:f58SaIzcDXrSy3kWaHNvuJgJ3Nmz59Zji6XoJR/q1ow= github.com/VividCortex/ewma v1.2.0/go.mod h1:nz4BbCtbLyFDeC9SUHbtcT5644juEuWfUAUnGx7j5l4= github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= diff --git a/vendor/github.com/VictoriaMetrics/metricsql/parser.go b/vendor/github.com/VictoriaMetrics/metricsql/parser.go index 12bd7d01a..209ed08fd 100644 --- a/vendor/github.com/VictoriaMetrics/metricsql/parser.go +++ b/vendor/github.com/VictoriaMetrics/metricsql/parser.go @@ -375,7 +375,7 @@ func (p *parser) parseExpr() (Expr, error) { if err := p.parseModifierExpr(&be.JoinModifier, true); err != nil { return nil, err } - if strings.ToLower(p.lex.Token) == "prefix" { + if isPrefixModifier(p.lex.Token) { if err := p.lex.Next(); err != nil { return nil, fmt.Errorf("cannot read prefix for %s: %w", be.JoinModifier.AppendString(nil), err) } @@ -1758,7 +1758,11 @@ func needBinaryOpArgParens(arg Expr) bool { } func isReservedBinaryOpIdent(s string) bool { - return isBinaryOpGroupModifier(s) || isBinaryOpJoinModifier(s) || isBinaryOpBoolModifier(s) + return isBinaryOpGroupModifier(s) || isBinaryOpJoinModifier(s) || isBinaryOpBoolModifier(s) || isPrefixModifier(s) +} + +func isPrefixModifier(s string) bool { + return strings.ToLower(s) == "prefix" } func appendArgInParens(dst []byte, arg Expr) []byte { diff --git a/vendor/modules.txt b/vendor/modules.txt index 58b1dd8b0..7956d8578 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -99,7 +99,7 @@ github.com/VictoriaMetrics/fasthttp/stackless # github.com/VictoriaMetrics/metrics v1.24.0 ## explicit; go 1.20 github.com/VictoriaMetrics/metrics -# github.com/VictoriaMetrics/metricsql v0.59.0 +# github.com/VictoriaMetrics/metricsql v0.59.1 ## explicit; go 1.13 github.com/VictoriaMetrics/metricsql github.com/VictoriaMetrics/metricsql/binaryop