Fixed fuzz test in UBSan

This commit is contained in:
Alexey Milovidov 2019-02-25 21:03:52 +03:00
parent c832124e6b
commit f02a834615
3 changed files with 13 additions and 0 deletions

View File

@ -33,6 +33,8 @@ namespace ErrorCodes
extern const int NUMBER_OF_ARGUMENTS_DOESNT_MATCH;
}
template <typename> class QuantileTiming;
/** Generic aggregate function for calculation of quantiles.
* It depends on quantile calculation data structure. Look at Quantile*.h for various implementations.
@ -82,6 +84,14 @@ public:
{
if (!returns_many && levels.size() > 1)
throw Exception("Aggregate function " + getName() + " require one parameter or less", ErrorCodes::NUMBER_OF_ARGUMENTS_DOESNT_MATCH);
if constexpr (std::is_same_v<Data, QuantileTiming<Value>>)
{
/// QuantileTiming only supports unsigned integers.
if (!isUnsignedInteger(argument_type))
throw Exception("Argument for function " + std::string(Name::name) + " must be unsigned integer, but it has type "
+ argument_type->getName(), ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT);
}
}
String getName() const override { return Name::name; }

View File

@ -0,0 +1,2 @@
SELECT quantileTiming(0.5)(number) FROM numbers(10);
SELECT quantileTiming(0.5)(number / 2) FROM numbers(10); -- { serverError 43 }