Merge pull request #52135 from ucasfl/alias

Add array_agg as alias of groupArray for PostgreSQL compatibility
This commit is contained in:
robot-ch-test-poll3 2023-07-15 21:14:38 +02:00 committed by GitHub
commit 9e7361a0f6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 19 additions and 0 deletions

View File

@ -44,3 +44,5 @@ Result:
```
The groupArray function will remove ᴺᵁᴸᴸ value based on the above results.
- Alias: `array_agg`.

View File

@ -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 });
}

View File

@ -0,0 +1,6 @@
['hello, world!','hello, world!','hello, world!','hello, world!','hello, world!']
['hello, world!']
['hello, world!']
['hello, world!']
['hello, world!']
['hello, world!']

View File

@ -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;