Skip to content

Commit

Permalink
Merge pull request #93869 from cockroachdb/blathers/backport-release-…
Browse files Browse the repository at this point in the history
…22.2-93868

release-22.2: colexec: fix range stats operator with the selection vector
  • Loading branch information
yuzefovich authored Dec 19, 2022
2 parents 9c44c2b + a82d21b commit cf1e7e6
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 2 additions & 0 deletions pkg/col/coldata/batch.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 3 additions & 1 deletion pkg/sql/colexec/range_stats.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand Down

0 comments on commit cf1e7e6

Please sign in to comment.