mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-12-19 12:52:37 +00:00
53 lines
1.8 KiB
C++
53 lines
1.8 KiB
C++
#pragma once
|
|
|
|
#include <AggregateFunctions/IAggregateFunction_fwd.h>
|
|
#include <Core/Field.h>
|
|
#include <DataTypes/DataTypeCustom.h>
|
|
|
|
#include <IO/ReadHelpers.h>
|
|
|
|
namespace DB
|
|
{
|
|
|
|
class IDataType;
|
|
using DataTypePtr = std::shared_ptr<const IDataType>;
|
|
using DataTypes = std::vector<DataTypePtr>;
|
|
|
|
/** 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)
|
|
*
|
|
* Technically, a standard IDataType is instantiated and customized with IDataTypeCustomName and DataTypeCustomDesc.
|
|
*/
|
|
|
|
class DataTypeCustomSimpleAggregateFunction : public IDataTypeCustomName
|
|
{
|
|
private:
|
|
const AggregateFunctionPtr function;
|
|
const DataTypes argument_types;
|
|
const Array parameters;
|
|
|
|
public:
|
|
DataTypeCustomSimpleAggregateFunction(const AggregateFunctionPtr & function_, const DataTypes & argument_types_, const Array & parameters_)
|
|
: function(function_), argument_types(argument_types_), parameters(parameters_) {}
|
|
|
|
AggregateFunctionPtr getFunction() const { return function; }
|
|
String getFunctionName() const;
|
|
const DataTypes & getArgumentsDataTypes() const { return argument_types; }
|
|
const Array & getParameters() const { return parameters; }
|
|
String getName() const override;
|
|
static void checkSupportedFunctions(const AggregateFunctionPtr & function);
|
|
};
|
|
|
|
DataTypePtr createSimpleAggregateFunctionType(const AggregateFunctionPtr & function, const DataTypes & argument_types, const Array & parameters);
|
|
|
|
}
|