Merge pull request #1641 from molecula/ma/cloud-119

CLOUD-119 CORE-653 Fix percentile query
This commit is contained in:
Mahesh Arumugam 2021-06-24 17:45:07 -07:00 committed by GitHub
commit 5187d3f862
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 8 additions and 2 deletions

View file

@ -1239,10 +1239,10 @@ func (e *executor) executePercentile(ctx context.Context, qcx *Qcx, index string
}
// get field
if fieldArg := c.Args["field"]; fieldArg == "" {
fieldName, err := c.FirstStringArg("field", "_field")
if err != nil {
return ValCount{}, errors.New("Percentile(): field required")
}
fieldName, _, _ := c.StringArg("field")
// filter call for min & max
var filterCall *pql.Call

View file

@ -7026,6 +7026,11 @@ func variousQueriesOnPercentiles(t *testing.T, c *test.Cluster) {
query: query,
csvVerifier: fmt.Sprintf("%d,1\n", expectedPercentile),
})
query2 := fmt.Sprintf(`Percentile(field=net_worth, filter=Row(val="foo"), nth=%d)`, nth)
tests = append(tests, testCase{
query: query2,
csvVerifier: fmt.Sprintf("%d,1\n", expectedPercentile),
})
}
for i, tst := range tests {

View file

@ -481,6 +481,7 @@ var callInfoByFunc = map[string]callInfo{
allowUnknown: false,
prototypes: map[string]interface{}{
"field": "",
"_field": "",
"filter": nil,
"nth": nil,
},