From eb1a92fdfe1347200cbba0d084c31449ae600c9c Mon Sep 17 00:00:00 2001 From: Rene van der Zee Date: Wed, 8 Nov 2023 16:05:14 +0100 Subject: [PATCH 1/3] Add SQL:2016 listagg This commit adds the SQL:2016 listagg function as an alias for string_agg --- src/core_functions/aggregate/distributive/functions.json | 2 +- src/core_functions/function_list.cpp | 1 + .../core_functions/aggregate/distributive_functions.hpp | 6 ++++++ 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/core_functions/aggregate/distributive/functions.json b/src/core_functions/aggregate/distributive/functions.json index 590fb622be2..6a31c152bdd 100644 --- a/src/core_functions/aggregate/distributive/functions.json +++ b/src/core_functions/aggregate/distributive/functions.json @@ -120,7 +120,7 @@ "description": "Concatenates the column string values with an optional separator.", "example": "string_agg(A, '-')", "type": "aggregate_function_set", - "aliases": ["group_concat"] + "aliases": ["group_concat","listagg"] }, { "name": "sum", diff --git a/src/core_functions/function_list.cpp b/src/core_functions/function_list.cpp index 9e9ef048320..d6a9331da2f 100644 --- a/src/core_functions/function_list.cpp +++ b/src/core_functions/function_list.cpp @@ -170,6 +170,7 @@ static StaticFunctionDefinition internal_functions[] = { DUCKDB_SCALAR_FUNCTION_SET(GreatestFun), DUCKDB_SCALAR_FUNCTION_SET(GreatestCommonDivisorFun), DUCKDB_AGGREGATE_FUNCTION_SET_ALIAS(GroupConcatFun), + DUCKDB_AGGREGATE_FUNCTION_SET_ALIAS(ListAggFun), DUCKDB_SCALAR_FUNCTION(HammingFun), DUCKDB_SCALAR_FUNCTION(HashFun), DUCKDB_SCALAR_FUNCTION_SET(HexFun), diff --git a/src/include/duckdb/core_functions/aggregate/distributive_functions.hpp b/src/include/duckdb/core_functions/aggregate/distributive_functions.hpp index a454620a9f2..a75eb3d01a5 100644 --- a/src/include/duckdb/core_functions/aggregate/distributive_functions.hpp +++ b/src/include/duckdb/core_functions/aggregate/distributive_functions.hpp @@ -210,6 +210,12 @@ struct GroupConcatFun { static constexpr const char *Name = "group_concat"; }; +struct ListAggFun { + using ALIAS = StringAggFun; + + static constexpr const char *Name = "listagg"; +}; + struct SumFun { static constexpr const char *Name = "sum"; static constexpr const char *Parameters = "arg"; From 3481de739268938ec5c7e4c8c548fdedbb3365d3 Mon Sep 17 00:00:00 2001 From: Rene van der Zee Date: Wed, 8 Nov 2023 18:59:30 +0100 Subject: [PATCH 2/3] Change ListAgg to Listagg --- src/core_functions/function_list.cpp | 2 +- .../duckdb/core_functions/aggregate/distributive_functions.hpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/core_functions/function_list.cpp b/src/core_functions/function_list.cpp index d6a9331da2f..538674df99d 100644 --- a/src/core_functions/function_list.cpp +++ b/src/core_functions/function_list.cpp @@ -170,7 +170,7 @@ static StaticFunctionDefinition internal_functions[] = { DUCKDB_SCALAR_FUNCTION_SET(GreatestFun), DUCKDB_SCALAR_FUNCTION_SET(GreatestCommonDivisorFun), DUCKDB_AGGREGATE_FUNCTION_SET_ALIAS(GroupConcatFun), - DUCKDB_AGGREGATE_FUNCTION_SET_ALIAS(ListAggFun), + DUCKDB_AGGREGATE_FUNCTION_SET_ALIAS(ListaggFun), DUCKDB_SCALAR_FUNCTION(HammingFun), DUCKDB_SCALAR_FUNCTION(HashFun), DUCKDB_SCALAR_FUNCTION_SET(HexFun), diff --git a/src/include/duckdb/core_functions/aggregate/distributive_functions.hpp b/src/include/duckdb/core_functions/aggregate/distributive_functions.hpp index a75eb3d01a5..6a918578826 100644 --- a/src/include/duckdb/core_functions/aggregate/distributive_functions.hpp +++ b/src/include/duckdb/core_functions/aggregate/distributive_functions.hpp @@ -210,7 +210,7 @@ struct GroupConcatFun { static constexpr const char *Name = "group_concat"; }; -struct ListAggFun { +struct ListaggFun { using ALIAS = StringAggFun; static constexpr const char *Name = "listagg"; From b83ae359a0bfde027e4441b29af1b11063038374 Mon Sep 17 00:00:00 2001 From: Rene van der Zee Date: Thu, 9 Nov 2023 16:14:34 +0100 Subject: [PATCH 3/3] generate_functions --- src/core_functions/function_list.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core_functions/function_list.cpp b/src/core_functions/function_list.cpp index 538674df99d..72d987a153b 100644 --- a/src/core_functions/function_list.cpp +++ b/src/core_functions/function_list.cpp @@ -170,7 +170,6 @@ static StaticFunctionDefinition internal_functions[] = { DUCKDB_SCALAR_FUNCTION_SET(GreatestFun), DUCKDB_SCALAR_FUNCTION_SET(GreatestCommonDivisorFun), DUCKDB_AGGREGATE_FUNCTION_SET_ALIAS(GroupConcatFun), - DUCKDB_AGGREGATE_FUNCTION_SET_ALIAS(ListaggFun), DUCKDB_SCALAR_FUNCTION(HammingFun), DUCKDB_SCALAR_FUNCTION(HashFun), DUCKDB_SCALAR_FUNCTION_SET(HexFun), @@ -214,6 +213,7 @@ static StaticFunctionDefinition internal_functions[] = { DUCKDB_SCALAR_FUNCTION(ListTransformFun), DUCKDB_SCALAR_FUNCTION(ListUniqueFun), DUCKDB_SCALAR_FUNCTION(ListValueFun), + DUCKDB_AGGREGATE_FUNCTION_SET_ALIAS(ListaggFun), DUCKDB_SCALAR_FUNCTION(LnFun), DUCKDB_SCALAR_FUNCTION_ALIAS(LogFun), DUCKDB_SCALAR_FUNCTION(Log10Fun),