diff --git a/executor.go b/executor.go index 9ee05633e..a97d74871 100644 --- a/executor.go +++ b/executor.go @@ -1306,8 +1306,8 @@ func (e *executor) executePercentile(ctx context.Context, qcx *Qcx, index string var nth float64 if nthArg, ok := c.Args["nth"].(pql.Decimal); ok { nth = nthArg.Float64() - if nth < 0 || nth > 1.0 { - return ValCount{}, errors.Errorf("Percentile(): invalid nth value(%f), should be >= 0 and <= 1.0", nth) + if nth < 0 || nth > 100.0 { + return ValCount{}, errors.Errorf("Percentile(): invalid nth value(%f), should be >= 0 and <= 100", nth) } } else { return ValCount{}, errors.New("Percentile(): nth required") diff --git a/executor_test.go b/executor_test.go index 3f33c8415..2f07b82f9 100644 --- a/executor_test.go +++ b/executor_test.go @@ -7053,7 +7053,7 @@ func variousQueriesOnPercentiles(t *testing.T, c *test.Cluster) { if nth == 0.0 { return min } - k := (1 - nth) / nth + k := (100 - nth) / nth possibleNthVal := int64(0) // bin search @@ -7127,7 +7127,7 @@ func variousQueriesOnPercentiles(t *testing.T, c *test.Cluster) { } // generate test cases per each nth argument - nths := []float64{0.0, 0.1, 0.25, 0.5, 0.75, 0.9, 0.99} + nths := []float64{0.0, 10, 25, 50, 75, 90, 99.99} var tests []testCase for _, nth := range nths { query := fmt.Sprintf(`Percentile(field="net_worth", filter=Row(val="foo"), nth=%f)`, nth)