Simple Aggregate Grouped

The simple aggregate grouped calling pattern totals the input values of all rows in the group and produces a result. _reset_extfn identifies the beginning of a group.

Query

select b, my_sum(a) from t group by b order by b

Calling pattern

_start_extfn(cntxt)
_reset_extfn(cntxt)
_next_value_extfn(cntxt, args)  -- input a=1
_next_value_extfn(cntxt, args)  -- input a=2
_next_value_extfn(cntxt, args)  -- input a=3
_evaluate_extfn(cntxt, args)    -- returns  6
_reset_extfn(cntxt)
_next_value_extfn(cntxt, args)  -- input a=4 
_next_value_extfn(cntxt, args)  -- input a=5
_next_value_extfn(cntxt, args)  -- input a=6
_evaluate_extfn(cntxt, args)    -- returns 15
_finish_extfn(cntxt)

Result

b,   my_sum(a)
1,   6
2,   15