From 25c817413bfd5be3710d53757ee4f5d3505a6b56 Mon Sep 17 00:00:00 2001 From: phiresky Date: Fri, 18 Dec 2020 13:10:35 +0100 Subject: [PATCH] pass context to finalize function --- src/functions.rs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/functions.rs b/src/functions.rs index f1a8dd8..e356629 100644 --- a/src/functions.rs +++ b/src/functions.rs @@ -248,7 +248,9 @@ where /// once, will be given `Some(A)` (the same `A` as was created by /// [`init`](Aggregate::init) and given to [`step`](Aggregate::step)); if [`step()`](Aggregate::step) was not called (because /// the function is running against 0 rows), will be given `None`. - fn finalize(&self, _: Option) -> Result; + /// + /// The passed context will have no arguments. + fn finalize(&self, _: &mut Context<'_>, _: Option) -> Result; } /// `feature = "window"` WindowAggregate is the callback interface for @@ -684,7 +686,11 @@ where !boxed_aggr.is_null(), "Internal error - null aggregate pointer" ); - (*boxed_aggr).finalize(a) + let mut ctx = Context { + ctx, + args: &mut [], + }; + (*boxed_aggr).finalize(&mut ctx, a) }); let t = match r { Err(_) => {