#include #include #include namespace DB { namespace { AggregateFunctionPtr createAggregateFunctionQuantileDeterministic(const std::string & name, const DataTypes & argument_types, const Array & parameters) { if (argument_types.size() != 2) throw Exception("Incorrect number of arguments for aggregate function " + name, ErrorCodes::NUMBER_OF_ARGUMENTS_DOESNT_MATCH); const auto determinator_type = argument_types[1].get(); if (!typeid_cast(determinator_type) && !typeid_cast(determinator_type) && !typeid_cast(determinator_type) && !typeid_cast(determinator_type)) { throw Exception{ "Illegal type " + determinator_type->getName() + " of second argument for aggregate function " + name + ", Int32, UInt32, Int64 or UInt64 required", ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT}; } const IDataType & argument_type = *argument_types[0]; if (typeid_cast(&argument_type)) return std::make_shared>(); else if (typeid_cast(&argument_type)) return std::make_shared>(); else if (typeid_cast(&argument_type)) return std::make_shared>(); else if (typeid_cast(&argument_type)) return std::make_shared>(); else if (typeid_cast(&argument_type)) return std::make_shared>(); else if (typeid_cast(&argument_type)) return std::make_shared>(); else if (typeid_cast(&argument_type)) return std::make_shared>(); else if (typeid_cast(&argument_type)) return std::make_shared>(); else if (typeid_cast(&argument_type)) return std::make_shared>(); else if (typeid_cast(&argument_type)) return std::make_shared>(); else if (typeid_cast(&argument_type)) return std::make_shared>(); else if (typeid_cast(&argument_type)) return std::make_shared>(); else throw Exception("Illegal type " + argument_types[0]->getName() + " of argument for aggregate function " + name, ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT); } AggregateFunctionPtr createAggregateFunctionQuantilesDeterministic(const std::string & name, const DataTypes & argument_types, const Array & parameters) { if (argument_types.size() != 2) throw Exception("Incorrect number of arguments for aggregate function " + name, ErrorCodes::NUMBER_OF_ARGUMENTS_DOESNT_MATCH); const auto determinator_type = argument_types[1].get(); if (!typeid_cast(determinator_type) && !typeid_cast(determinator_type) && !typeid_cast(determinator_type) && !typeid_cast(determinator_type)) { throw Exception{ "Illegal type " + determinator_type->getName() + " of second argument for aggregate function " + name + ", Int32, UInt32, Int64 or UInt64 required", ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT}; } const IDataType & argument_type = *argument_types[0]; if (typeid_cast(&argument_type)) return std::make_shared>(); else if (typeid_cast(&argument_type)) return std::make_shared>(); else if (typeid_cast(&argument_type)) return std::make_shared>(); else if (typeid_cast(&argument_type)) return std::make_shared>(); else if (typeid_cast(&argument_type)) return std::make_shared>(); else if (typeid_cast(&argument_type)) return std::make_shared>(); else if (typeid_cast(&argument_type)) return std::make_shared>(); else if (typeid_cast(&argument_type)) return std::make_shared>(); else if (typeid_cast(&argument_type)) return std::make_shared>(); else if (typeid_cast(&argument_type)) return std::make_shared>(); else if (typeid_cast(&argument_type)) return std::make_shared>(); else if (typeid_cast(&argument_type)) return std::make_shared>(); else throw Exception("Illegal type " + argument_types[0]->getName() + " of argument for aggregate function " + name, ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT); } } void registerAggregateFunctionsQuantileDeterministic(AggregateFunctionFactory & factory) { factory.registerFunction("quantileDeterministic", createAggregateFunctionQuantileDeterministic); factory.registerFunction("medianDeterministic", createAggregateFunctionQuantileDeterministic); factory.registerFunction("quantilesDeterministic", createAggregateFunctionQuantilesDeterministic); } }