Skip to content

Commit

Permalink
fix(chstorage): properly negate matchers
Browse files Browse the repository at this point in the history
  • Loading branch information
tdakkota committed Jun 7, 2024
1 parent f75bd30 commit a62d8ad
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion internal/chstorage/querier_logs.go
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,7 @@ func (q *Querier) Series(ctx context.Context, opts logstorage.SeriesOptions) (re
for _, sel := range sels {
selExprs := make([]chsql.Expr, 0, len(sel.Matchers))
for _, m := range sel.Matchers {
expr, err := q.logqlLabelMatcher(m, mapping)
expr, err := q.logQLLabelMatcher(m, mapping)
if err != nil {
return result, err
}
Expand Down
8 changes: 4 additions & 4 deletions internal/chstorage/querier_logs_query.go
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ func (p logQueryPredicates) write(
chsql.InTimeRange("timestamp", p.Start, p.End),
)
for _, m := range p.Labels {
expr, err := q.logqlLabelMatcher(m, mapping)
expr, err := q.logQLLabelMatcher(m, mapping)
if err != nil {
return err
}
Expand All @@ -335,7 +335,7 @@ func (p logQueryPredicates) write(

func (q *Querier) lineFilter(m logql.LineFilter) (e chsql.Expr, rerr error) {
defer func() {
if rerr != nil {
if rerr == nil {
switch m.Op {
case logql.OpNotEq, logql.OpNotRe:
e = chsql.Not(e)
Expand Down Expand Up @@ -367,12 +367,12 @@ func (q *Querier) lineFilter(m logql.LineFilter) (e chsql.Expr, rerr error) {
}
}

func (q *Querier) logqlLabelMatcher(
func (q *Querier) logQLLabelMatcher(
m logql.LabelMatcher,
mapping map[string]string,
) (e chsql.Expr, rerr error) {
defer func() {
if rerr != nil {
if rerr == nil {
switch m.Op {
case logql.OpNotEq, logql.OpNotRe:
e = chsql.Not(e)
Expand Down
2 changes: 1 addition & 1 deletion internal/chstorage/querier_metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ func (p *promQuerier) LabelNames(ctx context.Context, matchers ...*labels.Matche

func promQLLabelMatcher(valueSel []chsql.Expr, typ labels.MatchType, value string) (e chsql.Expr, rerr error) {
defer func() {
if rerr != nil {
if rerr == nil {
switch typ {
case labels.MatchNotEqual, labels.MatchNotRegexp:
e = chsql.Not(e)
Expand Down

0 comments on commit a62d8ad

Please sign in to comment.