From 7472e49b053fb5b080920203738995fe34d5add8 Mon Sep 17 00:00:00 2001 From: Matthew Nibecker Date: Sat, 28 Sep 2024 14:52:03 -0400 Subject: [PATCH] sort.New: Remove unnecessary error return value (#5305) --- compiler/kernel/op.go | 6 +----- runtime/sam/op/join/join.go | 11 ++--------- runtime/sam/op/sort/sort.go | 4 ++-- 3 files changed, 5 insertions(+), 16 deletions(-) diff --git a/compiler/kernel/op.go b/compiler/kernel/op.go index c47d65259a..df53baaebe 100644 --- a/compiler/kernel/op.go +++ b/compiler/kernel/op.go @@ -181,11 +181,7 @@ func (b *Builder) compileLeaf(o dag.Op, parent zbuf.Puller) (zbuf.Puller, error) } sortExprs = append(sortExprs, expr.NewSortEvaluator(k, s.Order)) } - sort, err := sort.New(b.rctx, parent, sortExprs, v.NullsFirst, v.Reverse, b.resetters) - if err != nil { - return nil, fmt.Errorf("compiling sort: %w", err) - } - return sort, nil + return sort.New(b.rctx, parent, sortExprs, v.NullsFirst, v.Reverse, b.resetters), nil case *dag.Head: limit := v.Count if limit == 0 { diff --git a/runtime/sam/op/join/join.go b/runtime/sam/op/join/join.go index d8047c2dae..87d3367a06 100644 --- a/runtime/sam/op/join/join.go +++ b/runtime/sam/op/join/join.go @@ -42,21 +42,14 @@ func New(rctx *runtime.Context, anti, inner bool, left, right zbuf.Puller, leftK case rightDir != order.Unknown: o = rightDir == order.Down } - var err error // Add sorts if needed. if !leftDir.HasOrder(o) { s := expr.NewSortEvaluator(leftKey, o) - left, err = sort.New(rctx, left, []expr.SortEvaluator{s}, false, false, resetter) - if err != nil { - return nil, err - } + left = sort.New(rctx, left, []expr.SortEvaluator{s}, false, false, resetter) } if !rightDir.HasOrder(o) { s := expr.NewSortEvaluator(rightKey, o) - right, err = sort.New(rctx, right, []expr.SortEvaluator{s}, false, false, resetter) - if err != nil { - return nil, err - } + right = sort.New(rctx, right, []expr.SortEvaluator{s}, false, false, resetter) } ctx, cancel := context.WithCancel(rctx.Context) return &Op{ diff --git a/runtime/sam/op/sort/sort.go b/runtime/sam/op/sort/sort.go index 051d216502..fdcca455b8 100644 --- a/runtime/sam/op/sort/sort.go +++ b/runtime/sam/op/sort/sort.go @@ -31,7 +31,7 @@ type Op struct { comparator *expr.Comparator } -func New(rctx *runtime.Context, parent zbuf.Puller, fields []expr.SortEvaluator, nullsFirst, reverse bool, resetter expr.Resetter) (*Op, error) { +func New(rctx *runtime.Context, parent zbuf.Puller, fields []expr.SortEvaluator, nullsFirst, reverse bool, resetter expr.Resetter) *Op { return &Op{ rctx: rctx, parent: parent, @@ -40,7 +40,7 @@ func New(rctx *runtime.Context, parent zbuf.Puller, fields []expr.SortEvaluator, reverse: reverse, fieldResolvers: fields, resultCh: make(chan op.Result), - }, nil + } } func (o *Op) Pull(done bool) (zbuf.Batch, error) {