2019-03-08 16:49:10 +00:00
|
|
|
#pragma once
|
|
|
|
|
2024-04-04 10:29:54 +00:00
|
|
|
#include <AggregateFunctions/IAggregateFunction_fwd.h>
|
|
|
|
#include <Core/Field.h>
|
2019-03-29 20:04:04 +00:00
|
|
|
#include <DataTypes/DataTypeCustom.h>
|
2019-03-08 16:49:10 +00:00
|
|
|
|
|
|
|
#include <IO/ReadHelpers.h>
|
|
|
|
|
|
|
|
namespace DB
|
|
|
|
{
|
|
|
|
|
2024-04-04 10:29:54 +00:00
|
|
|
class IDataType;
|
|
|
|
using DataTypePtr = std::shared_ptr<const IDataType>;
|
|
|
|
using DataTypes = std::vector<DataTypePtr>;
|
|
|
|
|
2019-03-08 16:49:10 +00:00
|
|
|
/** The type SimpleAggregateFunction(fct, type) is meant to be used in an AggregatingMergeTree. It behaves like a standard
|
|
|
|
* data type but when rows are merged, an aggregation function is applied.
|
|
|
|
*
|
|
|
|
* The aggregation function is limited to simple functions whose merge state is the final result:
|
|
|
|
* any, anyLast, min, max, sum
|
|
|
|
*
|
|
|
|
* Examples:
|
|
|
|
*
|
|
|
|
* SimpleAggregateFunction(sum, Nullable(Float64))
|
|
|
|
* SimpleAggregateFunction(anyLast, LowCardinality(Nullable(String)))
|
|
|
|
* SimpleAggregateFunction(anyLast, IPv4)
|
|
|
|
*
|
2020-08-08 00:47:03 +00:00
|
|
|
* Technically, a standard IDataType is instantiated and customized with IDataTypeCustomName and DataTypeCustomDesc.
|
2019-03-08 16:49:10 +00:00
|
|
|
*/
|
|
|
|
|
2019-03-29 20:04:04 +00:00
|
|
|
class DataTypeCustomSimpleAggregateFunction : public IDataTypeCustomName
|
2019-03-11 08:24:52 +00:00
|
|
|
{
|
2019-03-08 16:49:10 +00:00
|
|
|
private:
|
|
|
|
const AggregateFunctionPtr function;
|
|
|
|
const DataTypes argument_types;
|
|
|
|
const Array parameters;
|
|
|
|
|
|
|
|
public:
|
2019-03-29 20:04:04 +00:00
|
|
|
DataTypeCustomSimpleAggregateFunction(const AggregateFunctionPtr & function_, const DataTypes & argument_types_, const Array & parameters_)
|
2019-03-11 10:46:14 +00:00
|
|
|
: function(function_), argument_types(argument_types_), parameters(parameters_) {}
|
2019-03-08 16:49:10 +00:00
|
|
|
|
2022-03-12 17:46:38 +00:00
|
|
|
AggregateFunctionPtr getFunction() const { return function; }
|
2024-06-21 18:20:35 +00:00
|
|
|
String getFunctionName() const;
|
|
|
|
const DataTypes & getArgumentsDataTypes() const { return argument_types; }
|
|
|
|
const Array & getParameters() const { return parameters; }
|
2019-03-29 20:04:04 +00:00
|
|
|
String getName() const override;
|
2020-11-11 04:05:54 +00:00
|
|
|
static void checkSupportedFunctions(const AggregateFunctionPtr & function);
|
2019-03-08 16:49:10 +00:00
|
|
|
};
|
|
|
|
|
2024-06-21 18:20:35 +00:00
|
|
|
DataTypePtr createSimpleAggregateFunctionType(const AggregateFunctionPtr & function, const DataTypes & argument_types, const Array & parameters);
|
|
|
|
|
2019-03-08 16:49:10 +00:00
|
|
|
}
|