A user-defined aggregate is represented as an aggregate which calls its state function on each input row and then finalizes its execution by calling its final function on the final state, after all rows were already processed.