diff --git a/lib/logstorage/parser_test.go b/lib/logstorage/parser_test.go index b7f52551a..32c621421 100644 --- a/lib/logstorage/parser_test.go +++ b/lib/logstorage/parser_test.go @@ -929,6 +929,7 @@ func TestParseQuerySuccess(t *testing.T) { count() if (is_admin:true or _msg:"foo bar"*) as foo, sum(duration) if (host:in('foo.com', 'bar.com') and path:/foobar) as bar`, `* | stats by (_time:1d offset -2h, f2) count(*) if (is_admin:true or "foo bar"*) as foo, sum(duration) if (host:in(foo.com,bar.com) path:"/foobar") as bar`) + f(`* | stats count() if () rows`, `* | stats count(*) if () as rows`) // sort pipe f(`* | sort`, `* | sort`) diff --git a/lib/logstorage/pipe_stats.go b/lib/logstorage/pipe_stats.go index 0a19bb65b..fbcda809c 100644 --- a/lib/logstorage/pipe_stats.go +++ b/lib/logstorage/pipe_stats.go @@ -563,6 +563,10 @@ func parseIfFilter(lex *lexer) (filter, error) { return nil, fmt.Errorf("unexpected token %q after 'if'; expecting '('", lex.token) } lex.nextToken() + if lex.isKeyword(")") { + lex.nextToken() + return &filterNoop{}, nil + } f, err := parseFilter(lex) if err != nil { return nil, fmt.Errorf("cannot parse 'if' filter: %w", err)