Skip to content

Commit dc29d55

Browse files
committed
Aggregate Fns: Sum
Signed-off-by: Nicholas Gates <nick@nickgates.com>
1 parent b7d835a commit dc29d55

File tree

1 file changed

+14
-1
lines changed
  • vortex-array/src/aggregate_fn/fns/sum

1 file changed

+14
-1
lines changed

vortex-array/src/aggregate_fn/fns/sum/mod.rs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,20 @@ fn sum_output_ptype(ptype: PType) -> PType {
5757
///
5858
/// For primitive numeric types, the output is widened (unsigned -> u64, signed -> i64,
5959
/// float -> f64). For boolean inputs, `true` counts as 1 and `false` as 0, producing
60-
/// a u64 output.
60+
/// a u64 output. All output types are nullable.
61+
///
62+
/// # Flush semantics
63+
///
64+
/// - **Empty group** (flush with no prior accumulate/merge): produces **zero** (the additive
65+
/// identity).
66+
/// - **All-null group** (accumulate called but every value was null): produces **null**.
67+
/// - **Checked overflow**: produces **null**, and `is_saturated()` returns true so callers can
68+
/// skip further accumulation.
69+
///
70+
/// Note: this differs from the [`compute::sum`](crate::compute::sum) function, which treats
71+
/// both empty and all-null arrays identically (returning the zero accumulator). The aggregate
72+
/// distinguishes the two cases because all-null is semantically "unknown" while empty is
73+
/// "no data, so the identity applies".
6174
#[derive(Clone)]
6275
pub struct Sum;
6376

0 commit comments

Comments
 (0)