diff --git a/dbms/src/AggregateFunctions/AggregateFunctionQuantile.h b/dbms/src/AggregateFunctions/AggregateFunctionQuantile.h index f917fdc9742..fbd1d843a25 100644 --- a/dbms/src/AggregateFunctions/AggregateFunctionQuantile.h +++ b/dbms/src/AggregateFunctions/AggregateFunctionQuantile.h @@ -33,6 +33,8 @@ namespace ErrorCodes extern const int NUMBER_OF_ARGUMENTS_DOESNT_MATCH; } +template 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>) + { + /// 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; } diff --git a/dbms/tests/queries/0_stateless/00898_quantile_timing_parameter_check.reference b/dbms/tests/queries/0_stateless/00898_quantile_timing_parameter_check.reference new file mode 100644 index 00000000000..7ed6ff82de6 --- /dev/null +++ b/dbms/tests/queries/0_stateless/00898_quantile_timing_parameter_check.reference @@ -0,0 +1 @@ +5 diff --git a/dbms/tests/queries/0_stateless/00898_quantile_timing_parameter_check.sql b/dbms/tests/queries/0_stateless/00898_quantile_timing_parameter_check.sql new file mode 100644 index 00000000000..8279804a22c --- /dev/null +++ b/dbms/tests/queries/0_stateless/00898_quantile_timing_parameter_check.sql @@ -0,0 +1,2 @@ +SELECT quantileTiming(0.5)(number) FROM numbers(10); +SELECT quantileTiming(0.5)(number / 2) FROM numbers(10); -- { serverError 43 }