mirror of
https://github.com/featurebasedb/featurebase.git
synced 2026-10-06 19:07:50 +00:00
add new test cases for limits and clarify error messages
This commit is contained in:
parent
4c8dc8d54f
commit
13ec97abf5
2 changed files with 7 additions and 4 deletions
|
|
@ -1304,7 +1304,10 @@ func (e *executor) executePercentile(ctx context.Context, qcx *Qcx, index string
|
|||
|
||||
// get nth
|
||||
var nthFloat float64
|
||||
nthArg := c.Args["nth"]
|
||||
nthArg, ok := c.Args["nth"]
|
||||
if !ok {
|
||||
return ValCount{}, errors.New("Percentile(): nth required")
|
||||
}
|
||||
if nthArg == nil {
|
||||
return ValCount{}, errors.New("Percentile(): nth required")
|
||||
}
|
||||
|
|
@ -1314,10 +1317,10 @@ func (e *executor) executePercentile(ctx context.Context, qcx *Qcx, index string
|
|||
case int64:
|
||||
nthFloat = float64(nthArg)
|
||||
default:
|
||||
return ValCount{}, errors.Errorf("Percentile(): invalid nth='%v' of type (%[1]T), should be int64 or pql.Decimal", c.Args["nth"])
|
||||
return ValCount{}, errors.Errorf("Percentile(): invalid nth='%v' of type (%[1]T), should be a number between 0 and 100 inclusive", c.Args["nth"])
|
||||
}
|
||||
if nthFloat < 0 || nthFloat > 100.0 {
|
||||
return ValCount{}, errors.Errorf("Percentile(): invalid nth value (%f), should be between 0 and 100 inclusive", nthFloat)
|
||||
return ValCount{}, errors.Errorf("Percentile(): invalid nth value (%f), should be a number between 0 and 100 inclusive", nthFloat)
|
||||
}
|
||||
|
||||
// get field
|
||||
|
|
|
|||
|
|
@ -7137,7 +7137,7 @@ func variousQueriesOnPercentiles(t *testing.T, c *test.Cluster) {
|
|||
csvVerifier: fmt.Sprintf("%d,1\n", expectedPercentile),
|
||||
})
|
||||
}
|
||||
nthsInt := []int64{10}
|
||||
nthsInt := []int64{0, 10, 100}
|
||||
for _, nth := range nthsInt {
|
||||
query := fmt.Sprintf(`Percentile(field="net_worth", filter=Row(val="foo"), nth=%d)`, nth)
|
||||
expectedPercentile := getExpectedPercentile(nums, float64(nth))
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue