//===----------------------------------------------------------------------===// // DuckDB // // duckdb/execution/operator/aggregate/aggregate_object.hpp // // //===----------------------------------------------------------------------===// #pragma once #include "duckdb/execution/expression_executor.hpp" #include "duckdb/function/aggregate_function.hpp" namespace duckdb { class BoundAggregateExpression; class BoundWindowExpression; struct FunctionDataWrapper { FunctionDataWrapper(unique_ptr function_data_p) : function_data(std::move(function_data_p)) { } unique_ptr function_data; }; struct AggregateObject { AggregateObject(AggregateFunction function, FunctionData *bind_data, idx_t child_count, idx_t payload_size, AggregateType aggr_type, PhysicalType return_type, Expression *filter = nullptr); explicit AggregateObject(BoundAggregateExpression *aggr); explicit AggregateObject(BoundWindowExpression &window); FunctionData *GetFunctionData() const { return bind_data_wrapper ? bind_data_wrapper->function_data.get() : nullptr; } AggregateFunction function; shared_ptr bind_data_wrapper; idx_t child_count; idx_t payload_size; AggregateType aggr_type; PhysicalType return_type; Expression *filter = nullptr; public: bool IsDistinct() const { return aggr_type == AggregateType::DISTINCT; } static vector CreateAggregateObjects(const vector &bindings); }; struct AggregateFilterData { AggregateFilterData(ClientContext &context, Expression &filter_expr, const vector &payload_types); idx_t ApplyFilter(DataChunk &payload); ExpressionExecutor filter_executor; DataChunk filtered_payload; SelectionVector true_sel; }; struct AggregateFilterDataSet { AggregateFilterDataSet(); vector> filter_data; public: void Initialize(ClientContext &context, const vector &aggregates, const vector &payload_types); AggregateFilterData &GetFilterData(idx_t aggr_idx); }; } // namespace duckdb