Skip to content

Commit

Permalink
fix(chstorage): convert log abel value to string
Browse files Browse the repository at this point in the history
  • Loading branch information
tdakkota committed Jun 7, 2024
1 parent 19bcf51 commit 94ff446
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 10 deletions.
3 changes: 2 additions & 1 deletion internal/chstorage/attributes.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ func attrSelector(name, key string) chsql.Expr {
}

func firstAttrSelector(label string) chsql.Expr {
columns := make([]chsql.Expr, 0, 3)
columns := make([]chsql.Expr, 0, 4)
for _, column := range []string{
colAttrs,
colScope,
Expand All @@ -170,6 +170,7 @@ func firstAttrSelector(label string) chsql.Expr {
"Nullable(String)",
))
}
columns = append(columns, chsql.String(""))
return chsql.Coalesce(columns...)
}

Expand Down
4 changes: 2 additions & 2 deletions internal/chstorage/querier_logs_node.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ func (n *InputNode) EvalPipeline(ctx context.Context, params logqlengine.EvalPar
Line: n.Line,
Mapper: entryMapper,
}
return q.Eval(ctx, n.q)
return q.Execute(ctx, n.q)
}

func entryMapper(r logstorage.Record) (logqlengine.Entry, error) {
Expand Down Expand Up @@ -93,5 +93,5 @@ func (n *SamplingNode) EvalSample(ctx context.Context, params logqlengine.EvalPa
Labels: n.Labels,
Line: n.Line,
}
return q.Eval(ctx, n.q)
return q.Execute(ctx, n.q)
}
14 changes: 7 additions & 7 deletions internal/chstorage/querier_logs_query.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ type LogsQuery[E any] struct {
Mapper func(logstorage.Record) (E, error)
}

// Eval evaluates the query using given querier.
func (v *LogsQuery[E]) Eval(ctx context.Context, q *Querier) (_ iterators.Iterator[E], rerr error) {
// Execute executes the query using given querier.
func (v *LogsQuery[E]) Execute(ctx context.Context, q *Querier) (_ iterators.Iterator[E], rerr error) {
table := q.tables.Logs

ctx, span := q.tracer.Start(ctx, "chstorage.logs.LogsQuery.Eval",
Expand Down Expand Up @@ -114,7 +114,7 @@ func (v *LogsQuery[E]) Eval(ctx context.Context, q *Querier) (_ iterators.Iterat
Signal: "logs",
Table: table,
}); err != nil {
return nil, err
return nil, errors.Wrap(err, "execute LogsQuery")
}

return iterators.Slice(data), nil
Expand Down Expand Up @@ -146,8 +146,8 @@ func (c *sampleQueryColumns) Result() proto.Results {
}
}

// Eval evaluates the query using given querier.
func (v *SampleQuery) Eval(ctx context.Context, q *Querier) (_ logqlengine.SampleIterator, rerr error) {
// Execute executes the query using given querier.
func (v *SampleQuery) Execute(ctx context.Context, q *Querier) (_ logqlengine.SampleIterator, rerr error) {
table := q.tables.Logs

ctx, span := q.tracer.Start(ctx, "chstorage.logs.SampleQuery.Eval",
Expand Down Expand Up @@ -201,7 +201,7 @@ func (v *SampleQuery) Eval(ctx context.Context, q *Querier) (_ logqlengine.Sampl

entries = append(entries,
chsql.String(string(key)),
labelExpr,
chsql.ToString(labelExpr),
)
}

Expand Down Expand Up @@ -262,7 +262,7 @@ func (v *SampleQuery) Eval(ctx context.Context, q *Querier) (_ logqlengine.Sampl
Signal: "logs",
Table: table,
}); err != nil {
return nil, err
return nil, errors.Wrap(err, "execute SampleQuery")
}

return iterators.Slice(result), nil
Expand Down

0 comments on commit 94ff446

Please sign in to comment.