Skip to content

Commit

Permalink
opt: add assertion that selectivity is never NaN
Browse files Browse the repository at this point in the history
This commit addresses a leftover comment from cockroachdb#84366.

Release note: None
  • Loading branch information
rytaft committed Jul 13, 2022
1 parent 351498d commit 177816c
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion pkg/sql/opt/props/selectivity.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,12 @@

package props

import "fmt"
import (
"fmt"
"math"

"github.com/cockroachdb/errors"
)

// epsilon is the minimum value Selectivity can hold, since it cannot be 0.
const epsilon = 1e-10
Expand Down Expand Up @@ -100,6 +105,9 @@ func MaxSelectivity(a, b Selectivity) Selectivity {
// selectivityInRange performs the range check, if the selectivity falls
// outside of the range, this method will return the appropriate min/max value.
func selectivityInRange(sel float64) float64 {
if math.IsNaN(sel) {
panic(errors.AssertionFailedf("selectivity is NaN"))
}
switch {
case sel < epsilon:
return epsilon
Expand Down

0 comments on commit 177816c

Please sign in to comment.