mirror of
https://github.com/featurebasedb/featurebase.git
synced 2026-10-09 04:17:51 +00:00
Fix percentile query: field is mandatory (should not crash), fieldnames can be unquoted
This commit is contained in:
parent
3a678c9ce0
commit
357caf68c3
3 changed files with 8 additions and 2 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
|
|
|
|||
|
|
@ -481,6 +481,7 @@ var callInfoByFunc = map[string]callInfo{
|
|||
allowUnknown: false,
|
||||
prototypes: map[string]interface{}{
|
||||
"field": "",
|
||||
"_field": "",
|
||||
"filter": nil,
|
||||
"nth": nil,
|
||||
},
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue