diff --git a/pkg/col/coldata/batch.go b/pkg/col/coldata/batch.go index eea39f43f585..5c02fdbc5da2 100644 --- a/pkg/col/coldata/batch.go +++ b/pkg/col/coldata/batch.go @@ -47,6 +47,8 @@ type Batch interface { // Selection, if not nil, returns the selection vector on this batch: a // densely-packed list of the *increasing* indices in each column that have // not been filtered out by a previous step. + // TODO(yuzefovich): consider ensuring that the length of the returned slice + // equals the length of the batch. Selection() []int // SetSelection sets whether this batch is using its selection vector or not. SetSelection(bool) diff --git a/pkg/sql/colexec/range_stats.go b/pkg/sql/colexec/range_stats.go index d4c1d038075c..eab34f7f2ff2 100644 --- a/pkg/sql/colexec/range_stats.go +++ b/pkg/sql/colexec/range_stats.go @@ -108,7 +108,7 @@ func (r *rangeStatsOperator) Next() coldata.Batch { keysOutputIdx = append(keysOutputIdx, i) } } else { - for _, idx := range inSel { + for _, idx := range inSel[:batch.Length()] { if inNulls.MaybeHasNulls() && inNulls.NullAt(idx) { // Skip all NULL keys. continue @@ -127,6 +127,8 @@ func (r *rangeStatsOperator) Next() coldata.Batch { // TODO(ajwerner): Reserve memory for the responses. We know they'll // at least, on average, contain keys so it'll be 2x the size of the // keys plus some constant multiple. + // TODO(yuzefovich): add unit tests that use the RunTests test + // harness. res, err := r.fetcher.RangeStats(r.Ctx, keys...) if err != nil { colexecerror.ExpectedError(err)