From 0412a505c977544184b433c033f527f2e35e2316 Mon Sep 17 00:00:00 2001 From: Seebs Date: Wed, 29 Mar 2023 14:52:36 -0500 Subject: [PATCH] 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. --- sql3/planner/oppqlaggregate.go | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/sql3/planner/oppqlaggregate.go b/sql3/planner/oppqlaggregate.go index 20b867660..b8938d4bf 100644 --- a/sql3/planner/oppqlaggregate.go +++ b/sql3/planner/oppqlaggregate.go @@ -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: