Pass filters down to Percentile correctly

When pushing an expression down to PQL Percentile, if we have
a filter, it has to be passed as the argument "filter", not as
an additional child argument. We don't need to pass in `All()`
as a filter if there's no filter, Percentile works fine with
no filter provided.
This commit is contained in:
Seebs 2023-03-29 14:52:36 -05:00
parent 2bdc30c4f0
commit 1602a0ff06

View file

@ -230,17 +230,15 @@ func (i *pqlAggregateRowIter) Next(ctx context.Context) (types.Row, error) {
return nil, sql3.NewErrInternalf("unexpected aggregate nth arg type '%T'", coercedNthValue)
}
if cond == nil {
cond = &pql.Call{Name: "All"}
}
call = &pql.Call{
Name: "Percentile",
Args: map[string]interface{}{
"field": expr.columnName,
"nth": nth,
},
Children: []*pql.Call{cond},
}
if cond != nil {
call.Args["filter"] = cond
}
default: