Skip to content
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

Add array_agg as alias of groupArray for PostgreSQL compatibility #52135

Merged
merged 1 commit into from
Jul 15, 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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -44,3 +44,5 @@ Result:
```

The groupArray function will remove ᴺᵁᴸᴸ value based on the above results.

- Alias: `array_agg`.
1 change: 1 addition & 0 deletions src/AggregateFunctions/AggregateFunctionGroupArray.cpp
Expand Up @@ -125,6 +125,7 @@ void registerAggregateFunctionGroupArray(AggregateFunctionFactory & factory)
AggregateFunctionProperties properties = { .returns_default_when_only_null = false, .is_order_dependent = true };

factory.registerFunction("groupArray", { createAggregateFunctionGroupArray<false>, properties });
factory.registerAlias("array_agg", "groupArray", AggregateFunctionFactory::CaseInsensitive);
factory.registerFunction("groupArraySample", { createAggregateFunctionGroupArraySample, properties });
factory.registerFunction("groupArrayLast", { createAggregateFunctionGroupArray<true>, properties });
}
Expand Down
6 changes: 6 additions & 0 deletions tests/queries/0_stateless/02813_array_agg.reference
@@ -0,0 +1,6 @@
['hello, world!','hello, world!','hello, world!','hello, world!','hello, world!']
['hello, world!']
['hello, world!']
['hello, world!']
['hello, world!']
['hello, world!']
10 changes: 10 additions & 0 deletions tests/queries/0_stateless/02813_array_agg.sql
@@ -0,0 +1,10 @@
drop table if exists t;
create table t (n Int32, s String) engine=MergeTree order by n;

insert into t select number, 'hello, world!' from numbers (5);

select array_agg(s) from t;

select aRray_Agg(s) from t group by n;

drop table t;