diff --git a/engine/aggregator_operators.go b/engine/aggregator_operators.go index b32c2735bb4..8de242a5906 100644 --- a/engine/aggregator_operators.go +++ b/engine/aggregator_operators.go @@ -1508,6 +1508,10 @@ func NewTopOrBottomAggregator(name string, v *parser.Value, isTop bool, defaultV return nil, err } + if limit < 1 { + return nil, common.NewQueryError(common.InvalidArgument, fmt.Sprintf("function %s() second parameter must be > 0", name)) + } + return &TopOrBottomAggregator{ AbstractAggregator: AbstractAggregator{ value: v.Elems[0],