From f81c0cab6b6c243a104c5294f762a5c8f2b506e7 Mon Sep 17 00:00:00 2001 From: Matt Jaffee Date: Tue, 2 Mar 2021 21:59:46 -0600 Subject: [PATCH] move 0.0 check up to right after Min is queried --- executor.go | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/executor.go b/executor.go index 5025c01a2..dcd6ccd12 100644 --- a/executor.go +++ b/executor.go @@ -1336,6 +1336,9 @@ func (e *executor) executePercentile(ctx context.Context, qcx *Qcx, index string if err != nil { return ValCount{}, errors.Wrap(err, "executing Min call for Percentile") } + if nth == 0.0 { + return ValCount{Val: minVal.Val, Count: minVal.Count}, nil + } // get max q, _ = pql.ParseString(fmt.Sprintf(`Max(field="%s")`, fieldName)) @@ -1361,10 +1364,6 @@ 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