From eb2a5e8e5d22354f9b2d9b8ed4b0e9d423a8d325 Mon Sep 17 00:00:00 2001 From: Christiaan Herrewijn Date: Thu, 24 Oct 2024 12:50:22 +0200 Subject: [PATCH] reformat_aggregate_functions --- scripts/generate_functions.py | 2 +- .../operator/join/physical_hash_join.cpp | 3 +- src/execution/physical_plan/plan_distinct.cpp | 7 +- src/function/aggregate/CMakeLists.txt | 3 +- .../aggregate/distributive/CMakeLists.txt | 3 +- src/function/aggregate/distributive/count.cpp | 16 ++--- .../{first.cpp => first_last_any.cpp} | 27 ++++---- .../aggregate/distributive/functions.json | 52 ++++++++++++++ .../aggregate/distributive/minmax.cpp | 17 ++--- .../aggregate/distributive_functions.cpp | 17 ----- src/function/function.cpp | 2 - src/function/function_list.cpp | 10 +++ .../aggregate/distributive_function_utils.hpp | 31 +++++++++ .../aggregate/distributive_functions.hpp | 67 +++++++++++++++---- .../duckdb/function/built_in_functions.hpp | 3 - .../join_filter_pushdown_optimizer.cpp | 6 +- .../binder/query_node/bind_select_node.cpp | 4 +- .../binder/query_node/plan_subquery.cpp | 6 +- .../subquery/flatten_dependent_join.cpp | 6 +- 19 files changed, 197 insertions(+), 85 deletions(-) rename src/function/aggregate/distributive/{first.cpp => first_last_any.cpp} (97%) create mode 100644 src/function/aggregate/distributive/functions.json delete mode 100644 src/function/aggregate/distributive_functions.cpp create mode 100644 src/include/duckdb/function/aggregate/distributive_function_utils.hpp diff --git a/scripts/generate_functions.py b/scripts/generate_functions.py index 78792df2bf24..e258be5d0d8f 100644 --- a/scripts/generate_functions.py +++ b/scripts/generate_functions.py @@ -4,7 +4,7 @@ function_groups = { - ('src', 'include/duckdb', 'function'): ['scalar'], + ('src', 'include/duckdb', 'function'): ['scalar', 'aggregate'], ('extension', 'core_functions/include', 'core_functions'): ['scalar', 'aggregate'], } diff --git a/src/execution/operator/join/physical_hash_join.cpp b/src/execution/operator/join/physical_hash_join.cpp index 80896b6aee56..9d4e51a74f65 100644 --- a/src/execution/operator/join/physical_hash_join.cpp +++ b/src/execution/operator/join/physical_hash_join.cpp @@ -4,6 +4,7 @@ #include "duckdb/execution/expression_executor.hpp" #include "duckdb/execution/operator/aggregate/ungrouped_aggregate_state.hpp" #include "duckdb/function/aggregate/distributive_functions.hpp" +#include "duckdb/function/aggregate/distributive_function_utils.hpp" #include "duckdb/function/function_binder.hpp" #include "duckdb/main/client_context.hpp" #include "duckdb/main/query_profiler.hpp" @@ -248,7 +249,7 @@ unique_ptr PhysicalHashJoin::InitializeHashTable(ClientContext &c delim_payload_types.push_back(aggr->return_type); info.correlated_aggregates.push_back(std::move(aggr)); - auto count_fun = CountFun::GetFunction(); + auto count_fun = CountFunctionBase::GetFunction(); vector> children; // this is a dummy but we need it to make the hash table understand whats going on children.push_back(make_uniq_base(count_fun.return_type, 0U)); diff --git a/src/execution/physical_plan/plan_distinct.cpp b/src/execution/physical_plan/plan_distinct.cpp index 355169c33aa5..1eee79c823c9 100644 --- a/src/execution/physical_plan/plan_distinct.cpp +++ b/src/execution/physical_plan/plan_distinct.cpp @@ -1,7 +1,7 @@ #include "duckdb/execution/operator/aggregate/physical_hash_aggregate.hpp" #include "duckdb/execution/operator/projection/physical_projection.hpp" #include "duckdb/execution/physical_plan_generator.hpp" -#include "duckdb/function/aggregate/distributive_functions.hpp" +#include "duckdb/function/aggregate/distributive_function_utils.hpp" #include "duckdb/planner/expression/bound_aggregate_expression.hpp" #include "duckdb/planner/expression/bound_reference_expression.hpp" #include "duckdb/planner/operator/logical_distinct.hpp" @@ -59,8 +59,9 @@ unique_ptr PhysicalPlanGenerator::CreatePlan(LogicalDistinct & first_children.push_back(std::move(bound)); FunctionBinder function_binder(context); - auto first_aggregate = function_binder.BindAggregateFunction( - FirstFun::GetFunction(logical_type), std::move(first_children), nullptr, AggregateType::NON_DISTINCT); + auto first_aggregate = + function_binder.BindAggregateFunction(FirstFunctionGetter::GetFunction(logical_type), + std::move(first_children), nullptr, AggregateType::NON_DISTINCT); first_aggregate->order_bys = op.order_by ? op.order_by->Copy() : nullptr; if (ClientConfig::GetConfig(context).enable_optimizer) { diff --git a/src/function/aggregate/CMakeLists.txt b/src/function/aggregate/CMakeLists.txt index 843edfca284c..d607a91e693f 100644 --- a/src/function/aggregate/CMakeLists.txt +++ b/src/function/aggregate/CMakeLists.txt @@ -1,7 +1,6 @@ add_subdirectory(distributive) -add_library_unity(duckdb_func_aggr OBJECT distributive_functions.cpp - sorted_aggregate_function.cpp) +add_library_unity(duckdb_func_aggr OBJECT sorted_aggregate_function.cpp) set(ALL_OBJECT_FILES ${ALL_OBJECT_FILES} $ PARENT_SCOPE) diff --git a/src/function/aggregate/distributive/CMakeLists.txt b/src/function/aggregate/distributive/CMakeLists.txt index bf97c3ae1272..756462b384ea 100644 --- a/src/function/aggregate/distributive/CMakeLists.txt +++ b/src/function/aggregate/distributive/CMakeLists.txt @@ -1,4 +1,5 @@ -add_library_unity(duckdb_aggr_distr OBJECT count.cpp first.cpp minmax.cpp) +add_library_unity(duckdb_aggr_distr OBJECT count.cpp first_last_any.cpp + minmax.cpp) set(ALL_OBJECT_FILES ${ALL_OBJECT_FILES} $ PARENT_SCOPE) diff --git a/src/function/aggregate/distributive/count.cpp b/src/function/aggregate/distributive/count.cpp index d4e837aaa00d..0070fd583249 100644 --- a/src/function/aggregate/distributive/count.cpp +++ b/src/function/aggregate/distributive/count.cpp @@ -1,6 +1,7 @@ #include "duckdb/common/exception.hpp" #include "duckdb/common/vector_operations/vector_operations.hpp" #include "duckdb/function/aggregate/distributive_functions.hpp" +#include "duckdb/function/aggregate/distributive_function_utils.hpp" #include "duckdb/planner/expression/bound_aggregate_expression.hpp" namespace duckdb { @@ -210,7 +211,7 @@ struct CountFunction : public BaseCountFunction { } }; -AggregateFunction CountFun::GetFunction() { +AggregateFunction CountFunctionBase::GetFunction() { AggregateFunction fun({LogicalType(LogicalTypeId::ANY)}, LogicalType::BIGINT, AggregateFunction::StateSize, AggregateFunction::StateInitialize, CountFunction::CountScatter, AggregateFunction::StateCombine, @@ -241,21 +242,14 @@ unique_ptr CountPropagateStats(ClientContext &context, BoundAggr return nullptr; } -void CountFun::RegisterFunction(BuiltinFunctions &set) { - AggregateFunction count_function = CountFun::GetFunction(); +AggregateFunctionSet CountFun::GetFunctions() { + AggregateFunction count_function = CountFunctionBase::GetFunction(); count_function.statistics = CountPropagateStats; AggregateFunctionSet count("count"); count.AddFunction(count_function); // the count function can also be called without arguments - count_function = CountStarFun::GetFunction(); - count.AddFunction(count_function); - set.AddFunction(count); -} - -void CountStarFun::RegisterFunction(BuiltinFunctions &set) { - AggregateFunctionSet count("count_star"); count.AddFunction(CountStarFun::GetFunction()); - set.AddFunction(count); + return count; } } // namespace duckdb diff --git a/src/function/aggregate/distributive/first.cpp b/src/function/aggregate/distributive/first_last_any.cpp similarity index 97% rename from src/function/aggregate/distributive/first.cpp rename to src/function/aggregate/distributive/first_last_any.cpp index cbd63116f677..4a8979a55d02 100644 --- a/src/function/aggregate/distributive/first.cpp +++ b/src/function/aggregate/distributive/first_last_any.cpp @@ -1,6 +1,7 @@ #include "duckdb/common/exception.hpp" #include "duckdb/common/vector_operations/vector_operations.hpp" #include "duckdb/function/aggregate/distributive_functions.hpp" +#include "duckdb/function/aggregate/distributive_function_utils.hpp" #include "duckdb/function/create_sort_key.hpp" #include "duckdb/planner/expression.hpp" @@ -293,7 +294,7 @@ static AggregateFunction GetFirstFunction(const LogicalType &type) { } } -AggregateFunction FirstFun::GetFunction(const LogicalType &type) { +AggregateFunction FirstFunctionGetter::GetFunction(const LogicalType &type) { auto fun = GetFirstFunction(type); fun.name = "first"; return fun; @@ -340,22 +341,22 @@ static void AddFirstOperator(AggregateFunctionSet &set) { nullptr, BindFirst)); } -void FirstFun::RegisterFunction(BuiltinFunctions &set) { +AggregateFunctionSet FirstFun::GetFunctions() { AggregateFunctionSet first("first"); - AggregateFunctionSet last("last"); - AggregateFunctionSet any_value("any_value"); - AddFirstOperator(first); - AddFirstOperator(last); - AddFirstOperator(any_value); - - set.AddFunction(first); - first.name = "arbitrary"; - set.AddFunction(first); + return first; +} - set.AddFunction(last); +AggregateFunctionSet LastFun::GetFunctions() { + AggregateFunctionSet last("last"); + AddFirstOperator(last); + return last; +} - set.AddFunction(any_value); +AggregateFunctionSet AnyValueFun::GetFunctions() { + AggregateFunctionSet any_value("any_value"); + AddFirstOperator(any_value); + return any_value; } } // namespace duckdb diff --git a/src/function/aggregate/distributive/functions.json b/src/function/aggregate/distributive/functions.json new file mode 100644 index 000000000000..29284c6edbd6 --- /dev/null +++ b/src/function/aggregate/distributive/functions.json @@ -0,0 +1,52 @@ +[ + { + "name": "count_star", + "parameters": "", + "description": "", + "example": "", + "type": "aggregate_function" + }, + { + "name": "count", + "parameters": "arg", + "description": "Returns the number of non-null values in arg.", + "example": "count(A)", + "type": "aggregate_function_set" + }, + { + "name": "first", + "parameters": "arg", + "description": "Returns the first value (null or non-null) from arg. This function is affected by ordering.", + "example": "first(A)", + "type": "aggregate_function_set", + "aliases": ["arbitrary"] + }, + { + "name": "last", + "parameters": "arg", + "description": "Returns the last value of a column. This function is affected by ordering.", + "example": "last(A)", + "type": "aggregate_function_set" + }, + { + "name": "any_value", + "parameters": "arg", + "description": "Returns the first non-null value from arg. This function is affected by ordering.", + "example": "", + "type": "aggregate_function_set" + }, + { + "name": "min", + "parameters": "arg", + "description": "Returns the minimum value present in arg.", + "example": "min(A)", + "type": "aggregate_function_set" + }, + { + "name": "max", + "parameters": "arg", + "description": "Returns the maximum value present in arg.", + "example": "max(A)", + "type": "aggregate_function_set" + } +] diff --git a/src/function/aggregate/distributive/minmax.cpp b/src/function/aggregate/distributive/minmax.cpp index 122528d2582b..537140bf6eaf 100644 --- a/src/function/aggregate/distributive/minmax.cpp +++ b/src/function/aggregate/distributive/minmax.cpp @@ -4,6 +4,7 @@ #include "duckdb/common/types/null_value.hpp" #include "duckdb/common/vector_operations/vector_operations.hpp" #include "duckdb/function/aggregate/distributive_functions.hpp" +#include "duckdb/function/aggregate/distributive_function_utils.hpp" #include "duckdb/function/aggregate/minmax_n_helpers.hpp" #include "duckdb/function/aggregate/sort_key_helpers.hpp" #include "duckdb/function/function_binder.hpp" @@ -389,11 +390,11 @@ static AggregateFunction GetMinMaxOperator(string name) { nullptr, nullptr, BindMinMax); } -AggregateFunction MinFun::GetFunction() { +AggregateFunction MinFunction::GetFunction() { return GetMinMaxOperator("min"); } -AggregateFunction MaxFun::GetFunction() { +AggregateFunction MaxFunction::GetFunction() { return GetMinMaxOperator("max"); } @@ -537,18 +538,18 @@ static AggregateFunction GetMinMaxNFunction() { //--------------------------------------------------- // Function Registration //---------------------------------------------------s -void MinFun::RegisterFunction(BuiltinFunctions &set) { +AggregateFunctionSet MinFun::GetFunctions() { AggregateFunctionSet min("min"); - min.AddFunction(GetFunction()); + min.AddFunction(MinFunction::GetFunction()); min.AddFunction(GetMinMaxNFunction()); - set.AddFunction(min); + return min; } -void MaxFun::RegisterFunction(BuiltinFunctions &set) { +AggregateFunctionSet MaxFun::GetFunctions() { AggregateFunctionSet max("max"); - max.AddFunction(GetFunction()); + max.AddFunction(MaxFunction::GetFunction()); max.AddFunction(GetMinMaxNFunction()); - set.AddFunction(max); + return max; } } // namespace duckdb diff --git a/src/function/aggregate/distributive_functions.cpp b/src/function/aggregate/distributive_functions.cpp deleted file mode 100644 index d3125be48418..000000000000 --- a/src/function/aggregate/distributive_functions.cpp +++ /dev/null @@ -1,17 +0,0 @@ -#include "duckdb/function/aggregate/distributive_functions.hpp" -#include "duckdb/common/exception.hpp" -#include "duckdb/common/types/null_value.hpp" -#include "duckdb/common/vector_operations/vector_operations.hpp" -#include "duckdb/function/aggregate_function.hpp" - -namespace duckdb { - -void BuiltinFunctions::RegisterDistributiveAggregates() { - Register(); - Register(); - Register(); - Register(); - Register(); -} - -} // namespace duckdb diff --git a/src/function/function.cpp b/src/function/function.cpp index c34f63cae1e0..a1f8c9c712c1 100644 --- a/src/function/function.cpp +++ b/src/function/function.cpp @@ -94,8 +94,6 @@ void BuiltinFunctions::Initialize() { RegisterTableFunctions(); RegisterArrowFunctions(); - RegisterDistributiveAggregates(); - RegisterPragmaFunctions(); // initialize collations diff --git a/src/function/function_list.cpp b/src/function/function_list.cpp index f7b50d1fdf7c..a5d601a18048 100644 --- a/src/function/function_list.cpp +++ b/src/function/function_list.cpp @@ -1,4 +1,6 @@ #include "duckdb/function/function_list.hpp" + +#include "duckdb/function/aggregate/distributive_functions.hpp" #include "duckdb/function/scalar/compressed_materialization_functions.hpp" #include "duckdb/function/scalar/date_functions.hpp" #include "duckdb/function/scalar/generic_functions.hpp" @@ -66,6 +68,8 @@ static const StaticFunctionDefinition function[] = { DUCKDB_SCALAR_FUNCTION_SET(InternalDecompressIntegralUsmallintFun), DUCKDB_SCALAR_FUNCTION_SET(InternalDecompressStringFun), DUCKDB_SCALAR_FUNCTION_SET_ALIAS(AddFun), + DUCKDB_AGGREGATE_FUNCTION_SET(AnyValueFun), + DUCKDB_AGGREGATE_FUNCTION_SET_ALIAS(ArbitraryFun), DUCKDB_SCALAR_FUNCTION_ALIAS(ArrayCatFun), DUCKDB_SCALAR_FUNCTION_ALIAS(ArrayConcatFun), DUCKDB_SCALAR_FUNCTION_ALIAS(ArrayContainsFun), @@ -84,13 +88,17 @@ static const StaticFunctionDefinition function[] = { DUCKDB_SCALAR_FUNCTION(ConcatWsFun), DUCKDB_SCALAR_FUNCTION(ConstantOrNullFun), DUCKDB_SCALAR_FUNCTION_SET(ContainsFun), + DUCKDB_AGGREGATE_FUNCTION_SET(CountFun), + DUCKDB_AGGREGATE_FUNCTION(CountStarFun), DUCKDB_SCALAR_FUNCTION(CreateSortKeyFun), DUCKDB_SCALAR_FUNCTION(CurrvalFun), DUCKDB_SCALAR_FUNCTION_SET_ALIAS(DivideFun), DUCKDB_SCALAR_FUNCTION(ErrorFun), DUCKDB_SCALAR_FUNCTION(FinalizeFun), + DUCKDB_AGGREGATE_FUNCTION_SET(FirstFun), DUCKDB_SCALAR_FUNCTION(GetVariableFun), DUCKDB_SCALAR_FUNCTION(IlikeEscapeFun), + DUCKDB_AGGREGATE_FUNCTION_SET(LastFun), DUCKDB_SCALAR_FUNCTION_ALIAS(LcaseFun), DUCKDB_SCALAR_FUNCTION_SET_ALIAS(LenFun), DUCKDB_SCALAR_FUNCTION_SET(LengthFun), @@ -110,8 +118,10 @@ static const StaticFunctionDefinition function[] = { DUCKDB_SCALAR_FUNCTION(ListZipFun), DUCKDB_SCALAR_FUNCTION(LowerFun), DUCKDB_SCALAR_FUNCTION(MapContainsFun), + DUCKDB_AGGREGATE_FUNCTION_SET(MaxFun), DUCKDB_SCALAR_FUNCTION_SET(MD5Fun), DUCKDB_SCALAR_FUNCTION_SET(MD5NumberFun), + DUCKDB_AGGREGATE_FUNCTION_SET(MinFun), DUCKDB_SCALAR_FUNCTION_SET_ALIAS(ModFun), DUCKDB_SCALAR_FUNCTION_SET_ALIAS(MultiplyFun), DUCKDB_SCALAR_FUNCTION(NextvalFun), diff --git a/src/include/duckdb/function/aggregate/distributive_function_utils.hpp b/src/include/duckdb/function/aggregate/distributive_function_utils.hpp new file mode 100644 index 000000000000..cdaed691c92d --- /dev/null +++ b/src/include/duckdb/function/aggregate/distributive_function_utils.hpp @@ -0,0 +1,31 @@ +//===----------------------------------------------------------------------===// +// DuckDB +// +// duckdb/function/aggregate/distributive_functions.hpp +// +// +//===----------------------------------------------------------------------===// + +#pragma once + +#include "duckdb/function/function_set.hpp" + +namespace duckdb { + +struct CountFunctionBase { + static AggregateFunction GetFunction(); +}; + +struct FirstFunctionGetter { + static AggregateFunction GetFunction(const LogicalType &type); +}; + +struct MinFunction { + static AggregateFunction GetFunction(); +}; + +struct MaxFunction { + static AggregateFunction GetFunction(); +}; + +} // namespace duckdb diff --git a/src/include/duckdb/function/aggregate/distributive_functions.hpp b/src/include/duckdb/function/aggregate/distributive_functions.hpp index 83b18d2e05c8..7d6eb3274cfc 100644 --- a/src/include/duckdb/function/aggregate/distributive_functions.hpp +++ b/src/include/duckdb/function/aggregate/distributive_functions.hpp @@ -1,48 +1,87 @@ //===----------------------------------------------------------------------===// // DuckDB // -// duckdb/function/aggregate/distributive_functions.hpp +// function/aggregate/distributive_functions.hpp // // //===----------------------------------------------------------------------===// +// This file is automatically generated by scripts/generate_functions.py +// Do not edit this file manually, your changes will be overwritten +//===----------------------------------------------------------------------===// #pragma once -#include "duckdb/function/aggregate_function.hpp" #include "duckdb/function/function_set.hpp" -#include "duckdb/common/types/null_value.hpp" -#include "duckdb/function/built_in_functions.hpp" namespace duckdb { struct CountStarFun { - static AggregateFunction GetFunction(); + static constexpr const char *Name = "count_star"; + static constexpr const char *Parameters = ""; + static constexpr const char *Description = ""; + static constexpr const char *Example = ""; - static void RegisterFunction(BuiltinFunctions &set); + static AggregateFunction GetFunction(); }; struct CountFun { - static AggregateFunction GetFunction(); + static constexpr const char *Name = "count"; + static constexpr const char *Parameters = "arg"; + static constexpr const char *Description = "Returns the number of non-null values in arg."; + static constexpr const char *Example = "count(A)"; - static void RegisterFunction(BuiltinFunctions &set); + static AggregateFunctionSet GetFunctions(); }; struct FirstFun { - static AggregateFunction GetFunction(const LogicalType &type); + static constexpr const char *Name = "first"; + static constexpr const char *Parameters = "arg"; + static constexpr const char *Description = "Returns the first value (null or non-null) from arg. This function is affected by ordering."; + static constexpr const char *Example = "first(A)"; - static void RegisterFunction(BuiltinFunctions &set); + static AggregateFunctionSet GetFunctions(); +}; + +struct ArbitraryFun { + using ALIAS = FirstFun; + + static constexpr const char *Name = "arbitrary"; +}; + +struct LastFun { + static constexpr const char *Name = "last"; + static constexpr const char *Parameters = "arg"; + static constexpr const char *Description = "Returns the last value of a column. This function is affected by ordering."; + static constexpr const char *Example = "last(A)"; + + static AggregateFunctionSet GetFunctions(); +}; + +struct AnyValueFun { + static constexpr const char *Name = "any_value"; + static constexpr const char *Parameters = "arg"; + static constexpr const char *Description = "Returns the first non-null value from arg. This function is affected by ordering."; + static constexpr const char *Example = ""; + + static AggregateFunctionSet GetFunctions(); }; struct MinFun { - static AggregateFunction GetFunction(); + static constexpr const char *Name = "min"; + static constexpr const char *Parameters = "arg"; + static constexpr const char *Description = "Returns the minimum value present in arg."; + static constexpr const char *Example = "min(A)"; - static void RegisterFunction(BuiltinFunctions &set); + static AggregateFunctionSet GetFunctions(); }; struct MaxFun { - static AggregateFunction GetFunction(); + static constexpr const char *Name = "max"; + static constexpr const char *Parameters = "arg"; + static constexpr const char *Description = "Returns the maximum value present in arg."; + static constexpr const char *Example = "max(A)"; - static void RegisterFunction(BuiltinFunctions &set); + static AggregateFunctionSet GetFunctions(); }; } // namespace duckdb diff --git a/src/include/duckdb/function/built_in_functions.hpp b/src/include/duckdb/function/built_in_functions.hpp index c4a287af41e4..fb8ef3166303 100644 --- a/src/include/duckdb/function/built_in_functions.hpp +++ b/src/include/duckdb/function/built_in_functions.hpp @@ -54,9 +54,6 @@ class BuiltinFunctions { void RegisterArrowFunctions(); void RegisterSnifferFunction(); - // aggregates - void RegisterDistributiveAggregates(); - void RegisterExtensionOverloads(); // pragmas diff --git a/src/optimizer/join_filter_pushdown_optimizer.cpp b/src/optimizer/join_filter_pushdown_optimizer.cpp index 16bedfc4d741..c59734474d64 100644 --- a/src/optimizer/join_filter_pushdown_optimizer.cpp +++ b/src/optimizer/join_filter_pushdown_optimizer.cpp @@ -2,7 +2,7 @@ #include "duckdb/execution/operator/join/join_filter_pushdown.hpp" #include "duckdb/execution/operator/join/physical_comparison_join.hpp" -#include "duckdb/function/aggregate/distributive_functions.hpp" +#include "duckdb/function/aggregate/distributive_function_utils.hpp" #include "duckdb/function/function_binder.hpp" #include "duckdb/optimizer/optimizer.hpp" #include "duckdb/planner/expression/bound_aggregate_expression.hpp" @@ -213,8 +213,8 @@ void JoinFilterPushdownOptimizer::GenerateJoinFilters(LogicalComparisonJoin &joi } // set up the min/max aggregates for each of the filters vector aggr_functions; - aggr_functions.push_back(MinFun::GetFunction()); - aggr_functions.push_back(MaxFun::GetFunction()); + aggr_functions.push_back(MinFunction::GetFunction()); + aggr_functions.push_back(MaxFunction::GetFunction()); for (auto &join_condition : pushdown_info->join_condition) { for (auto &aggr : aggr_functions) { FunctionBinder function_binder(optimizer.GetContext()); diff --git a/src/planner/binder/query_node/bind_select_node.cpp b/src/planner/binder/query_node/bind_select_node.cpp index 6ee65633a83c..93e0b60c5a7f 100644 --- a/src/planner/binder/query_node/bind_select_node.cpp +++ b/src/planner/binder/query_node/bind_select_node.cpp @@ -1,7 +1,7 @@ #include "duckdb/common/limits.hpp" #include "duckdb/common/string_util.hpp" #include "duckdb/execution/expression_executor.hpp" -#include "duckdb/function/aggregate/distributive_functions.hpp" +#include "duckdb/function/aggregate/distributive_function_utils.hpp" #include "duckdb/function/function_binder.hpp" #include "duckdb/main/config.hpp" #include "duckdb/parser/expression/columnref_expression.hpp" @@ -492,7 +492,7 @@ unique_ptr Binder::BindSelectNode(SelectNode &statement, unique_ // but also push a first(x) aggregate in case x is selected (uncollated) info.collated_groups[i] = result->aggregates.size(); - auto first_fun = FirstFun::GetFunction(bound_expr_ref.return_type); + auto first_fun = FirstFunctionGetter::GetFunction(bound_expr_ref.return_type); vector> first_children; // FIXME: would be better to just refer to this expression, but for now we copy first_children.push_back(bound_expr_ref.Copy()); diff --git a/src/planner/binder/query_node/plan_subquery.cpp b/src/planner/binder/query_node/plan_subquery.cpp index 6526093dff27..807fa6c7b494 100644 --- a/src/planner/binder/query_node/plan_subquery.cpp +++ b/src/planner/binder/query_node/plan_subquery.cpp @@ -1,4 +1,5 @@ #include "duckdb/function/aggregate/distributive_functions.hpp" +#include "duckdb/function/aggregate/distributive_function_utils.hpp" #include "duckdb/main/client_config.hpp" #include "duckdb/planner/binder.hpp" #include "duckdb/planner/expression/bound_aggregate_expression.hpp" @@ -87,8 +88,9 @@ static unique_ptr PlanUncorrelatedSubquery(Binder &binder, BoundSubq first_children.push_back(std::move(bound)); FunctionBinder function_binder(binder.context); - auto first_agg = function_binder.BindAggregateFunction( - FirstFun::GetFunction(expr.return_type), std::move(first_children), nullptr, AggregateType::NON_DISTINCT); + auto first_agg = + function_binder.BindAggregateFunction(FirstFunctionGetter::GetFunction(expr.return_type), + std::move(first_children), nullptr, AggregateType::NON_DISTINCT); expressions.push_back(std::move(first_agg)); if (error_on_multiple_rows) { diff --git a/src/planner/subquery/flatten_dependent_join.cpp b/src/planner/subquery/flatten_dependent_join.cpp index ac36e9eaef4c..bbd98b2cf71a 100644 --- a/src/planner/subquery/flatten_dependent_join.cpp +++ b/src/planner/subquery/flatten_dependent_join.cpp @@ -3,6 +3,7 @@ #include "duckdb/catalog/catalog_entry/aggregate_function_catalog_entry.hpp" #include "duckdb/common/operator/add.hpp" #include "duckdb/function/aggregate/distributive_functions.hpp" +#include "duckdb/function/aggregate/distributive_function_utils.hpp" #include "duckdb/planner/binder.hpp" #include "duckdb/planner/expression/bound_aggregate_expression.hpp" #include "duckdb/planner/expression/list.hpp" @@ -240,7 +241,7 @@ unique_ptr FlattenDependentJoins::PushDownDependentJoinInternal delim_data_offset = aggr.groups.size(); for (idx_t i = 0; i < correlated_columns.size(); i++) { auto &col = correlated_columns[i]; - auto first_aggregate = FirstFun::GetFunction(col.type); + auto first_aggregate = FirstFunctionGetter::GetFunction(col.type); auto colref = make_uniq( col.name, col.type, ColumnBinding(base_binding.table_index, base_binding.column_index + i)); vector> aggr_children; @@ -300,7 +301,8 @@ unique_ptr FlattenDependentJoins::PushDownDependentJoinInternal D_ASSERT(aggr.expressions[i]->GetExpressionClass() == ExpressionClass::BOUND_AGGREGATE); auto &bound = aggr.expressions[i]->Cast(); vector arguments; - if (bound.function == CountFun::GetFunction() || bound.function == CountStarFun::GetFunction()) { + if (bound.function == CountFunctionBase::GetFunction() || + bound.function == CountStarFun::GetFunction()) { // have to replace this ColumnBinding with the CASE expression replacement_map[ColumnBinding(aggr.aggregate_index, i)] = i; }