This commit is contained in:
Aliaksandr Valialkin 2024-05-17 13:29:38 +02:00
parent 0b4c103edb
commit db75ec4dac
No known key found for this signature in database
GPG key ID: 52C003EE2BCDB9EB
2 changed files with 5 additions and 0 deletions

View file

@ -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`)

View file

@ -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)