sum
Computes the sum of values.
null
values are ignored.
All primitive numeric types are supported: Byte
, Short
, Int
, Long
, Float
, and Double
.
sum
also supports the "mixed" Number
type, as long as the column consists only of the aforementioned primitive numbers. The numbers are automatically converted to a common type for the operation.
All operations on Double
/Float
/Number
have the skipNaN
option, which is set to false
by default. This means that if a NaN
is present in the input, it will be propagated to the result. When it's set to true
, NaN
values are ignored.
See statistics for details on complex data aggregations.
Type Conversion
The following automatic type conversions are performed for the sum
operation:
Conversion | Result for Empty Input |
---|---|
Int -> Int | 0 |
Byte -> Int | 0 |
Short -> Int | 0 |
Long -> Long | 0L |
Double -> Double | 0.0 |
Float -> Float | 0.0f |
Number -> Conversion(Common number type) -> Number | 0.0 |
Nothing -> Double | 0.0 |