mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-21 15:12:02 +00:00
dbms: prohibit narrow-width integral types for determinator of quantile(s)Deterministic. [#METR-13199]
This commit is contained in:
parent
d0971956e0
commit
eaa8a75a63
@ -22,6 +22,7 @@
|
||||
namespace detail
|
||||
{
|
||||
const size_t DEFAULT_SAMPLE_COUNT = 8192;
|
||||
const auto MAX_SKIP_DEGREE = sizeof(UInt32) * 8;
|
||||
}
|
||||
|
||||
/// Что делать, если нет ни одного значения - кинуть исключение, или вернуть 0 или NaN в случае double?
|
||||
@ -66,9 +67,10 @@ public:
|
||||
|
||||
void insertImpl(const T & v, const UInt32 hash)
|
||||
{
|
||||
if (samples.size() == sample_count)
|
||||
while (samples.size() + 1 >= sample_count)
|
||||
{
|
||||
++skip_degree;
|
||||
if (++skip_degree > detail::MAX_SKIP_DEGREE)
|
||||
throw DB::Exception{"skip_degree exceeds maximum value", DB::ErrorCodes::MEMORY_LIMIT_EXCEEDED};
|
||||
thinOut();
|
||||
}
|
||||
|
||||
|
@ -331,6 +331,19 @@ AggregateFunctionPtr AggregateFunctionFactory::get(const String & name, const Da
|
||||
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<const DataTypeInt32 *>(determinator_type) &&
|
||||
!typeid_cast<const DataTypeUInt32 *>(determinator_type) &&
|
||||
!typeid_cast<const DataTypeInt64 *>(determinator_type) &&
|
||||
!typeid_cast<const DataTypeUInt64 *>(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<const DataTypeUInt8 *>(&argument_type)) return new AggregateFunctionQuantileDeterministic<UInt8>;
|
||||
@ -353,6 +366,19 @@ AggregateFunctionPtr AggregateFunctionFactory::get(const String & name, const Da
|
||||
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<const DataTypeInt32 *>(determinator_type) &&
|
||||
!typeid_cast<const DataTypeUInt32 *>(determinator_type) &&
|
||||
!typeid_cast<const DataTypeInt64 *>(determinator_type) &&
|
||||
!typeid_cast<const DataTypeUInt64 *>(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<const DataTypeUInt8 *>(&argument_type)) return new AggregateFunctionQuantilesDeterministic<UInt8>;
|
||||
|
Loading…
Reference in New Issue
Block a user