Skip to content

Commit 379bb89

Browse files
authored
Merge pull request #10708 from b41sh/feat-list-func
feat(function): Add `list` Aggregate function
2 parents d2be911 + 0164d89 commit 379bb89

File tree

12 files changed

+731
-18
lines changed

12 files changed

+731
-18
lines changed
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
---
2+
title: LIST
3+
---
4+
5+
Aggregate function.
6+
7+
The LIST() function converts all the values of a column to an Array.
8+
9+
## Syntax
10+
11+
```sql
12+
LIST(expression)
13+
```
14+
15+
## Arguments
16+
17+
| Arguments | Description |
18+
| ----------- | -------------- |
19+
| expression | Any expression |
20+
21+
## Return Type
22+
23+
the Array type that use the type of the value as inner type.
24+
25+
## Examples
26+
27+
```sql
28+
SELECT LIST(number) FROM numbers(10);
29+
+-----------------------+
30+
| list(number) |
31+
+-----------------------+
32+
| [0,1,2,3,4,5,6,7,8,9] |
33+
+-----------------------+
34+
```

docs/doc/15-sql-functions/10-aggregate-functions/index.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,5 @@ These functions help you extract and summarize data from databases to gain valua
3030
| [QUANTILE](aggregate-quantile.md) | Calculates the quantile for a specific column |
3131
| [RETENTION](aggregate-retention.md) | Calculates retention for a set of events |
3232
| [WINDOW_FUNNEL](aggregate-windowfunnel.md) | Analyzes user behavior in a time-ordered sequence of events |
33+
| [LIST](aggregate-list.md) | Converts all the values of a column to an Array |
3334

src/query/functions/src/aggregates/aggregate_function_factory.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,12 @@ impl AggregateFunctionFactory {
157157
) -> Result<AggregateFunctionRef> {
158158
let name = name.as_ref();
159159
let mut features = AggregateFunctionFeatures::default();
160+
// The NULL value in the list function needs to be added to the returned array column,
161+
// so handled separately.
162+
if name == "list" {
163+
let agg = self.get_impl(name, params, arguments, &mut features)?;
164+
return Ok(agg);
165+
}
160166

161167
if !arguments.is_empty() && arguments.iter().any(|f| f.is_nullable_or_null()) {
162168
let new_params = AggregateFunctionCombinatorNull::transform_params(&params)?;

0 commit comments

Comments
 (0)