Skip to content

Commit 6d92802

Browse files
committed
fix lint
Signed-off-by: yeya24 <[email protected]>
1 parent 7564510 commit 6d92802

File tree

3 files changed

+14
-15
lines changed

3 files changed

+14
-15
lines changed

engine/pushdown_test.go

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,17 @@ package engine_test
22

33
import (
44
"context"
5-
"errors"
65
"fmt"
76
"math/rand"
87
"strconv"
98
"testing"
109
"time"
1110

11+
"github.com/thanos-io/promql-engine/engine"
12+
"github.com/thanos-io/promql-engine/logicalplan"
13+
1214
"github.com/cortexproject/promqlsmith"
15+
"github.com/efficientgo/core/errors"
1316
"github.com/efficientgo/core/testutil"
1417
"github.com/google/go-cmp/cmp"
1518
"github.com/prometheus/prometheus/model/labels"
@@ -19,8 +22,6 @@ import (
1922
"github.com/prometheus/prometheus/storage"
2023
"github.com/prometheus/prometheus/tsdb/chunkenc"
2124
"github.com/prometheus/prometheus/util/annotations"
22-
"github.com/thanos-io/promql-engine/engine"
23-
"github.com/thanos-io/promql-engine/logicalplan"
2425
)
2526

2627
type projectionQuerier struct {
@@ -88,7 +89,7 @@ func (m projectionSeriesSet) At() storage.Series {
8889
}
8990
}
9091

91-
// projectedSeries wraps a storage.Series but returns projected labels
92+
// projectedSeries wraps a storage.Series but returns projected labels.
9293
type projectedSeries struct {
9394
storage.Series
9495
lset labels.Labels
@@ -105,7 +106,7 @@ func (s *projectedSeries) Iterator(iter chunkenc.Iterator) chunkenc.Iterator {
105106
func (m projectionSeriesSet) Err() error { return m.SeriesSet.Err() }
106107
func (m projectionSeriesSet) Warnings() annotations.Annotations { return m.SeriesSet.Warnings() }
107108

108-
// Implement the Querier interface methods
109+
// Implement the Querier interface methods.
109110
func (m *projectionQuerier) Select(ctx context.Context, sortSeries bool, hints *storage.SelectHints, matchers ...*labels.Matcher) storage.SeriesSet {
110111
return projectionSeriesSet{
111112
SeriesSet: m.Querier.Select(ctx, sortSeries, hints, matchers...),
@@ -120,7 +121,7 @@ func (m *projectionQuerier) LabelNames(ctx context.Context, _ *storage.LabelHint
120121
}
121122
func (m *projectionQuerier) Close() error { return nil }
122123

123-
// projectionQueryable is a storage.Queryable that applies projection to the querier
124+
// projectionQueryable is a storage.Queryable that applies projection to the querier.
124125
type projectionQueryable struct {
125126
storage.Queryable
126127
}
@@ -256,7 +257,7 @@ func TestProjectionPushdownWithFuzz(t *testing.T) {
256257
}
257258
}
258259

259-
// containsAggregationOrBinaryOperation checks if the expression contains any aggregation or binary operations
260+
// containsAggregationOrBinaryOperation checks if the expression contains any aggregation or binary operations.
260261
func containsAggregationOrBinaryOperation(expr parser.Expr) bool {
261262
found := false
262263
parser.Inspect(expr, func(node parser.Node, _ []parser.Node) error {

logicalplan/projection_pushdown.go

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
package logicalplan
22

33
import (
4+
"github.com/thanos-io/promql-engine/query"
5+
46
"github.com/prometheus/prometheus/promql/parser"
57
"github.com/prometheus/prometheus/util/annotations"
6-
"github.com/thanos-io/promql-engine/query"
78
)
89

910
type ProjectionPushdown struct {
@@ -15,9 +16,7 @@ func (p ProjectionPushdown) Optimize(plan Node, _ *query.Options) (Node, annotat
1516
return plan, nil
1617
}
1718

18-
// pushProjection recursively traverses the tree and pushes projection information down
19-
// - requiredLabels: the set of labels required by parent nodes
20-
// - isWithout: whether the projection should exclude (true) or include (false) the labels
19+
// pushProjection recursively traverses the tree and pushes projection information down.
2120
func (p ProjectionPushdown) pushProjection(node *Node, requiredLabels map[string]struct{}, isWithout bool) {
2221
switch n := (*node).(type) {
2322
case *VectorSelector:
@@ -123,16 +122,14 @@ func stringSet(s []string) map[string]struct{} {
123122
return set
124123
}
125124

126-
// unwrapStepInvariantExpr recursively unwraps step invariant expressions to get to the underlying node
125+
// unwrapStepInvariantExpr recursively unwraps step invariant expressions to get to the underlying node.
127126
func unwrapStepInvariantExpr(node Node) Node {
128127
if stepInvariant, ok := node.(*StepInvariantExpr); ok {
129128
return unwrapStepInvariantExpr(stepInvariant.Expr)
130129
}
131130
return node
132131
}
133132

134-
// getFunctionLabelRequirements ensures that specific labels required by functions are included
135-
// in the projection
136133
func getFunctionLabelRequirements(funcName string, args []Node, requiredLabels map[string]struct{}, isWithout bool) map[string]struct{} {
137134
if requiredLabels == nil {
138135
return nil

logicalplan/projection_pushdown_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,10 @@ import (
77
"testing"
88
"time"
99

10+
"github.com/thanos-io/promql-engine/query"
11+
1012
"github.com/efficientgo/core/testutil"
1113
"github.com/prometheus/prometheus/promql/parser"
12-
"github.com/thanos-io/promql-engine/query"
1314
)
1415

1516
func TestProjectionPushdown(t *testing.T) {

0 commit comments

Comments
 (0)