Skip to content

Commit

Permalink
Merge branch 'main' into fix_objectexists_for_file_mock
Browse files Browse the repository at this point in the history
  • Loading branch information
MichelHollands authored Jan 24, 2024
2 parents c74ee66 + 6d66ea3 commit 19dfbda
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 0 deletions.
2 changes: 2 additions & 0 deletions pkg/logql/syntax/ast.go
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,8 @@ func newNestedLineFilterExpr(left *LineFilterExpr, right *LineFilterExpr) *LineF
return &LineFilterExpr{
Left: left,
LineFilter: right.LineFilter,
Or: right.Or,
IsOrChild: right.IsOrChild,
}
}

Expand Down
15 changes: 15 additions & 0 deletions pkg/logql/syntax/ast_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -383,6 +383,13 @@ func Test_FilterMatcher(t *testing.T) {
},
[]linecheck{{"foo", true}, {"bar", true}, {"none", false}},
},
{
`{app="foo"} |= "foo" or "bar" |= "buzz" or "fizz"`,
[]*labels.Matcher{
mustNewMatcher(labels.MatchEqual, "app", "foo"),
},
[]linecheck{{"foo buzz", true}, {"bar fizz", true}, {"foo", false}, {"bar", false}, {"none", false}},
},
{
`{app="foo"} != "foo" or "bar"`,
[]*labels.Matcher{
Expand Down Expand Up @@ -496,6 +503,14 @@ func TestStringer(t *testing.T) {
in: `{app="foo"} |~ "foo" or "bar" or "baz"`,
out: `{app="foo"} |~ "foo" or "bar" or "baz"`,
},
{
in: `{app="foo"} |= "foo" or "bar" |= "buzz" or "fizz"`,
out: `{app="foo"} |= "foo" or "bar" |= "buzz" or "fizz"`,
},
{
out: `{app="foo"} |= "foo" or "bar" |~ "buzz|fizz"`,
in: `{app="foo"} |= "foo" or "bar" |~ "buzz|fizz"`,
},
{
in: `{app="foo"} |= ip("127.0.0.1") or "foo"`,
out: `{app="foo"} |= ip("127.0.0.1") or "foo"`,
Expand Down
35 changes: 35 additions & 0 deletions pkg/logql/syntax/parser_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3138,6 +3138,41 @@ var ParseTestCases = []struct {
},
},
},
{
in: `{app="foo"} |= "foo" or "bar" |= "buzz" or "fizz"`,
exp: &PipelineExpr{
Left: newMatcherExpr([]*labels.Matcher{mustNewMatcher(labels.MatchEqual, "app", "foo")}),
MultiStages: MultiStageExpr{
&LineFilterExpr{
Left: newOrLineFilter(
&LineFilterExpr{
LineFilter: LineFilter{
Ty: labels.MatchEqual,
Match: "foo",
},
},
&LineFilterExpr{
LineFilter: LineFilter{
Ty: labels.MatchEqual,
Match: "bar",
},
}),
LineFilter: LineFilter{
Ty: labels.MatchEqual,
Match: "buzz",
},
Or: &LineFilterExpr{
LineFilter: LineFilter{
Ty: labels.MatchEqual,
Match: "fizz",
},
IsOrChild: true,
},
IsOrChild: false,
},
},
},
},
}

func TestParse(t *testing.T) {
Expand Down

0 comments on commit 19dfbda

Please sign in to comment.