From 94ff446c572be62ad932256796e9235924c568c6 Mon Sep 17 00:00:00 2001 From: tdakkota Date: Fri, 7 Jun 2024 18:23:41 +0300 Subject: [PATCH] fix(chstorage): convert log abel value to string --- internal/chstorage/attributes.go | 3 ++- internal/chstorage/querier_logs_node.go | 4 ++-- internal/chstorage/querier_logs_query.go | 14 +++++++------- 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/internal/chstorage/attributes.go b/internal/chstorage/attributes.go index 80a922c6..2195fd66 100644 --- a/internal/chstorage/attributes.go +++ b/internal/chstorage/attributes.go @@ -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, @@ -170,6 +170,7 @@ func firstAttrSelector(label string) chsql.Expr { "Nullable(String)", )) } + columns = append(columns, chsql.String("")) return chsql.Coalesce(columns...) } diff --git a/internal/chstorage/querier_logs_node.go b/internal/chstorage/querier_logs_node.go index a534132b..4bbc2ab8 100644 --- a/internal/chstorage/querier_logs_node.go +++ b/internal/chstorage/querier_logs_node.go @@ -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) { @@ -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) } diff --git a/internal/chstorage/querier_logs_query.go b/internal/chstorage/querier_logs_query.go index 1fe3b9de..42354782 100644 --- a/internal/chstorage/querier_logs_query.go +++ b/internal/chstorage/querier_logs_query.go @@ -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", @@ -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 @@ -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", @@ -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), ) } @@ -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