Skip to content

Commit

Permalink
query/physicalplan: Guard against s.size==0 panic
Browse files Browse the repository at this point in the history
Please take a look at this fix, @thorfour. I'm not sure why this started panicking now.
  • Loading branch information
metalmatze committed Nov 26, 2024
1 parent 3cb86d7 commit 192c12a
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions query/physicalplan/sampler.go
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,10 @@ func (s *ReservoirSampler) sliceReservoir() {

// sample implements the reservoir sampling algorithm found https://en.wikipedia.org/wiki/Reservoir_sampling.
func (s *ReservoirSampler) sample(r arrow.Record, ref *referencedRecord) {
// The size can be 0 and in that case we don't want to sample.
if s.size == 0 {
return
}
n := s.n + r.NumRows()
if s.i == 0 {
s.i = float64(s.n) - 1
Expand Down

0 comments on commit 192c12a

Please sign in to comment.