Fix errors on creating pql Call

This commit is contained in:
nagamocha3000 2021-02-23 22:55:14 +03:00 • committed by Matt Jaffee
parent d740a0cda7
commit 3fb79b4d97
No known key found for this signature in database
GPG key ID: 08A3DFFF987B11BF
2 changed files with 4 additions and 5 deletions

View file

@ -1322,15 +1322,14 @@ func (e *executor) executePercentile(ctx context.Context, qcx *Qcx, index string
return ValCount{}, errors.Wrap(err, "executing Max call for Percentile")
}
// set up reusables
countQuery, _ := pql.ParseString("Count(Row(fld < 0))")
countQuery, _ := pql.ParseString(fmt.Sprintf("Count(Row(%s < 0))", fieldName))
countCall := countQuery.Calls[0]
rangeQuery, _ := pql.ParseString("Row(fld < 0)")
rangeCall := rangeQuery.Calls[0]
rangeCall := countCall.Children[0]
min, max := minVal.Val, maxVal.Val
// estimate nth val, eg median when nth=0.5
for min < max {
possibleNthVal := (max - min) / 2
possibleNthVal := (max + min) / 2
// get left count
rangeCall.Args[fieldName] = &pql.Condition{
Op: pql.Token(pql.LT),

View file

@ -6896,7 +6896,7 @@ func variousQueriesOnPercentiles(t *testing.T, clusterSize int) {
// Rows
{
query: `Percentile(field="net_worth", nth=0.5)`,
csvVerifier: "10,1\n",
csvVerifier: "40,1\n",
},
}