> ## Documentation Index
> Fetch the complete documentation index at: /documents/llms.txt
> Use this file to discover all available pages before exploring further.

# array_cum_sum

> 返回数组中元素的累加和构成的数组。

对数组中的元素进行向前累加。

## 语法

```Haskell theme={null}
array_cum_sum(array(bigint))
array_cum_sum(array(double))
```

## 参数说明

`array`：需要处理的数组。支持的数据类型为 BIGINT（8 字节有符号整型）和 DOUBLE (8 字节浮点数)。

## 返回值说明

返回和输入数组类型相同的数组。

## 示例

示例一：对数组中的元素向前累加。

```plain text theme={null}
select array_cum_sum([11, 11, 12]);
+---------------------------+
| array_cum_sum([11,11,12]) |
+---------------------------+
| [11,22,34]                |
+---------------------------+
```

示例二：与 CAST 函数搭配使用。

```plain text theme={null}
select array_cum_sum([cast(11.33 as double),cast(11.11 as double),cast(12.324 as double)]);
+---------------------------------------------------------------------------------------+
| array_cum_sum([CAST(11.33 AS DOUBLE), CAST(11.11 AS DOUBLE), CAST(12.324 AS DOUBLE)]) |
+---------------------------------------------------------------------------------------+
| [11.33,22.439999999999998,34.763999999999996]                                         |
+---------------------------------------------------------------------------------------+
```

示例三：数组中包含 null 值。

```plain text theme={null}
select array_cum_sum([null,1,2]);
+---------------------------------+
| array_cum_sum([null,1,2])       |
+---------------------------------+
| [null,1,3]                      |
+---------------------------------+
```

示例四：输入数组为 NULL。

```plain text theme={null}
select array_cum_sum(null);
+---------------------------------+
| array_cum_sum(NULL)             |
+---------------------------------+
| NULL                            |
+---------------------------------+
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.