Skip to content

feat(function): Add list Aggregate function #10708

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions docs/doc/15-sql-functions/10-aggregate-functions/aggregate-list.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
---
title: LIST
---

Aggregate function.

The LIST() function converts all the values of a column to an Array.

## Syntax

```sql
LIST(expression)
```

## Arguments

| Arguments | Description |
| ----------- | -------------- |
| expression | Any expression |

## Return Type

the Array type that use the type of the value as inner type.

## Examples

```sql
SELECT LIST(number) FROM numbers(10);
+-----------------------+
| list(number) |
+-----------------------+
| [0,1,2,3,4,5,6,7,8,9] |
+-----------------------+
```
1 change: 1 addition & 0 deletions docs/doc/15-sql-functions/10-aggregate-functions/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,5 @@ These functions help you extract and summarize data from databases to gain valua
| [QUANTILE](aggregate-quantile.md) | Calculates the quantile for a specific column |
| [RETENTION](aggregate-retention.md) | Calculates retention for a set of events |
| [WINDOW_FUNNEL](aggregate-windowfunnel.md) | Analyzes user behavior in a time-ordered sequence of events |
| [LIST](aggregate-list.md) | Converts all the values of a column to an Array |

Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,12 @@ impl AggregateFunctionFactory {
) -> Result<AggregateFunctionRef> {
let name = name.as_ref();
let mut features = AggregateFunctionFeatures::default();
// The NULL value in the list function needs to be added to the returned array column,
// so handled separately.
if name == "list" {
let agg = self.get_impl(name, params, arguments, &mut features)?;
return Ok(agg);
}

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