Sum of array elements(数组元素求和(Sum of array elements))¶
Supported in: Batch, Faster, Streaming
Sums the elements contained within the array.
Expression categories: Array
Declared arguments¶
- Expression: An array of numeric types to be summed.
Expression\> - optional Treat null as zero: If true, nulls inside the array are treated as zero, and arrays containing null can be summed. If false, the presence of a null makes the entire array null.
Literal\
Type variable bounds: T accepts DefiniteNumeric
Output type: T
Examples¶
Example 1: Base case¶
Argument values:
- Expression: [ 1, 2, 3 ]
- Treat null as zero: true
Output: 6
Example 2: Null case¶
Argument values:
- Expression: [ 1, 2, 3, null ]
- Treat null as zero: false
Output: null
Example 3: Null case¶
Argument values:
- Expression: [ 1, 2, 3, null ]
- Treat null as zero: true
Output: 6
Example 4: Null case¶
Argument values:
- Expression:
array - Treat null as zero: true
| array | Output |
|---|---|
| null | null |
中文翻译¶
数组元素求和(Sum of array elements)¶
支持:批处理(Batch)、快速处理(Faster)、流处理(Streaming)
对数组中的元素进行求和。
表达式类别: 数组(Array)
声明的参数¶
- 表达式(Expression): 待求和的数值类型数组。
Expression\> - 可选 将空值视为零(Treat null as zero): 若为 true,数组中的空值(null)将被视为零,包含空值的数组仍可求和;若为 false,只要存在空值,整个数组结果即为空值。
Literal\
类型变量约束: T 接受 DefiniteNumeric
输出类型: T
示例¶
示例 1:基础情况¶
参数值:
- 表达式: [ 1, 2, 3 ]
- 将空值视为零: true
输出: 6
示例 2:空值情况¶
参数值:
- 表达式: [ 1, 2, 3, null ]
- 将空值视为零: false
输出: null
示例 3:空值情况¶
参数值:
- 表达式: [ 1, 2, 3, null ]
- 将空值视为零: true
输出: 6
示例 4:空值情况¶
参数值:
- 表达式:
array - 将空值视为零: true
| array | 输出 |
|---|---|
| null | null |