Expand description
Exact SUM / AVG accumulation, shared by every aggregate path.
The rule, applied the same way everywhere:
- An integer input adds exactly into an
i128. Au64abovei64::MAXand an integralDecimalare integer inputs. - A fractional
Decimaladds exactly into aDecimal. - A float input adds into a Neumaier-compensated
f64. Once the float total is not finite, compensation stops and the total stays as IEEE arithmetic gives it: an overflow isInfinity,Infinityplus-Infinityis NaN, as in PostgreSQL. - A numeric string is the number it spells: an integer, or a
Decimalwhen it has a fraction. ADECIMALcell is stored as its text, so this keeps aDECIMALcolumn exact. - SUM with only integer inputs is an
Integerwhen the total fitsi64. A larger total is aDecimal. - SUM with a fractional
Decimalinput and no float input is aDecimal: the exact integer part plus the exact decimal part. - An exact total past the
Decimalrange isEvalError::NumericOverflow. - SUM with at least one float input is a
Float: the exact parts plus the float part. - AVG is a
Float. With no float input it divides the exact total by the count, with no rounding of the total first. - SUM and AVG over no input are NULL.
- Two partial accumulators merge without loss: the integer parts add exactly, so a shard or spill merge gives the single-pass result.
STDDEV and VARIANCE stay in f64 (Welford); they are not exact sums.
Structs§
- Exact
Sum - Running exact SUM / AVG state. See the module docs for the rule.
Functions§
- numeric_
text - The number a numeric string spells, exactly where it can be: an integer
as [
numeric_to_value] gives it, a fraction in decimal notation as aDecimal, and any other numeric text (an exponent, a fraction past theDecimalprecision) as aFloat.Nonefor non-numeric text. - sum_
input - A SUM / AVG argument value as the number it contributes: a number as
itself, a numeric string as the number it spells (see
numeric_text).Nonefor any other value, which contributes nothing.