diff --git a/lib/logstorage/parser.go b/lib/logstorage/parser.go index d6f6e5b78..cb87e363f 100644 --- a/lib/logstorage/parser.go +++ b/lib/logstorage/parser.go @@ -398,7 +398,7 @@ func ParseQuery(s string) (*Query, error) { return nil, err } if !lex.isEnd() { - return nil, fmt.Errorf("unexpected unparsed tail; context: [%s]; tail: [%s]", lex.context(), lex.s) + return nil, fmt.Errorf("unexpected unparsed tail after [%s]; context: [%s]; tail: [%s]", q, lex.context(), lex.s) } return q, nil } @@ -582,7 +582,7 @@ func getCompoundFuncArg(lex *lexer) string { rawArg := lex.rawToken lex.nextToken() suffix := "" - for !lex.isSkippedSpace && !lex.isKeyword("*", ",", ")", "|", "") { + for !lex.isSkippedSpace && !lex.isKeyword("*", ",", "(", ")", "|", "") { suffix += lex.rawToken lex.nextToken() } diff --git a/lib/logstorage/parser_test.go b/lib/logstorage/parser_test.go index 340a6a5ed..e69994e12 100644 --- a/lib/logstorage/parser_test.go +++ b/lib/logstorage/parser_test.go @@ -713,6 +713,7 @@ func TestParseQuerySuccess(t *testing.T) { f(`in(err|fields x)`, `in(err | fields x)`) f(`ip:in(foo and user:in(admin, moderator)|fields ip)`, `ip:in(foo user:in(admin,moderator) | fields ip)`) f(`x:in(_time:5m y:in(*|fields z) | stats by (q) count() rows|fields q)`, `x:in(_time:5m y:in(* | fields z) | stats by (q) count(*) as rows | fields q)`) + f(`in(bar:in(1,2,3) | uniq (x)) | stats count() rows`, `in(bar:in(1,2,3) | uniq by (x)) | stats count(*) as rows`) // ipv4_range filter f(`ipv4_range(1.2.3.4, "5.6.7.8")`, `ipv4_range(1.2.3.4, 5.6.7.8)`)