#include #include #include namespace DB { namespace { /** DataForVariadic - структура с данными, которая будет использоваться для агрегатной функции uniq от множества аргументов. * Отличается, например, тем, что использует тривиальную хэш-функцию, так как uniq от множества аргументов сначала самостоятельно их хэширует. */ template AggregateFunctionPtr createAggregateFunctionUniq(const std::string & name, const DataTypes & argument_types) { if (argument_types.size() == 1) { const IDataType & argument_type = *argument_types[0]; AggregateFunctionPtr res(createWithNumericType(*argument_types[0])); if (res) return res; 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) || 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); } else if (argument_types.size() > 1) { /// Если аргументов несколько, то среди них недопустимо наличие кортежей. for (const auto & type : argument_types) if (typeid_cast(type.get())) throw Exception("Tuple argument of function " + name + " must be the only argument", ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT); return std::make_shared>(); } else throw Exception("Incorrect number of arguments for aggregate function " + name, ErrorCodes::NUMBER_OF_ARGUMENTS_DOESNT_MATCH); } template