mirror of
https://github.com/featurebasedb/featurebase.git
synced 2026-09-11 07:11:02 +00:00
handle 0th percentile properly
This commit is contained in:
parent
b1f9e6ad05
commit
1e4cc12bd0
2 changed files with 8 additions and 1 deletions
|
|
@ -1361,6 +1361,10 @@ func (e *executor) executePercentile(ctx context.Context, qcx *Qcx, index string
|
|||
rangeCall = intersectCall.Children[0]
|
||||
}
|
||||
|
||||
if nth == 0.0 {
|
||||
return ValCount{Val: minVal.Val, Count: minVal.Count}, nil
|
||||
}
|
||||
|
||||
k := (1 - nth) / nth
|
||||
|
||||
min, max := minVal.Val, maxVal.Val
|
||||
|
|
|
|||
|
|
@ -6916,6 +6916,9 @@ func variousQueriesOnPercentiles(t *testing.T, c *test.Cluster) {
|
|||
max = num
|
||||
}
|
||||
}
|
||||
if nth == 0.0 {
|
||||
return min
|
||||
}
|
||||
k := (1 - nth) / nth
|
||||
|
||||
possibleNthVal := int64(0)
|
||||
|
|
@ -6990,7 +6993,7 @@ func variousQueriesOnPercentiles(t *testing.T, c *test.Cluster) {
|
|||
}
|
||||
|
||||
// generate test cases per each nth argument
|
||||
nths := []float64{0.1, 0.25, 0.5, 0.75, 0.9, 0.99}
|
||||
nths := []float64{0.0, 0.1, 0.25, 0.5, 0.75, 0.9, 0.99}
|
||||
var tests []testCase
|
||||
for _, nth := range nths {
|
||||
query := fmt.Sprintf(`Percentile(field="net_worth", filter=Row(val="foo"), nth=%f)`, nth)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue