Returned back support for floating point argument in function quantileTiming

This commit is contained in:
Alexey Milovidov 2019-07-07 02:15:14 +03:00
parent a1cfdf2a60
commit e8b6ac3fad
5 changed files with 19 additions and 17 deletions

View File

@ -82,14 +82,6 @@ public:
{ {
if (!returns_many && levels.size() > 1) if (!returns_many && levels.size() > 1)
throw Exception("Aggregate function " + getName() + " require one parameter or less", ErrorCodes::NUMBER_OF_ARGUMENTS_DOESNT_MATCH); 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 integers (it works only for unsigned integers but signed are also accepted for convenience).
if (!isInteger(argument_type))
throw Exception("Argument for function " + std::string(Name::name) + " must be integer, but it has type "
+ argument_type->getName(), ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT);
}
} }
String getName() const override { return Name::name; } String getName() const override { return Name::name; }
@ -111,16 +103,21 @@ public:
void add(AggregateDataPtr place, const IColumn ** columns, size_t row_num, Arena *) const override void add(AggregateDataPtr place, const IColumn ** columns, size_t row_num, Arena *) const override
{ {
/// Out of range conversion may occur. This is Ok. auto value = static_cast<const ColVecType &>(*columns[0]).getData()[row_num];
const auto & column = static_cast<const ColVecType &>(*columns[0]); if constexpr (std::is_same_v<Data, QuantileTiming<Value>>)
{
/// QuantileTiming only supports integers.
if (isNaN(value) || value > std::numeric_limits<Value>::max() || value < std::numeric_limits<Value>::min())
return;
}
if constexpr (has_second_arg) if constexpr (has_second_arg)
this->data(place).add( this->data(place).add(
column.getData()[row_num], value,
columns[1]->getUInt(row_num)); columns[1]->getUInt(row_num));
else else
this->data(place).add(column.getData()[row_num]); this->data(place).add(value);
} }
void merge(AggregateDataPtr place, ConstAggregateDataPtr rhs, Arena *) const override void merge(AggregateDataPtr place, ConstAggregateDataPtr rhs, Arena *) const override

View File

@ -6,6 +6,10 @@
['2016-06-15 23:00:00'] ['2016-06-15 23:00:00']
2016-06-15 23:00:00 2016-06-15 23:00:00
['2016-06-15 23:00:00'] ['2016-06-15 23:00:00']
30000
[30000]
30000
[30000]
2016-06-15 23:01:04 2016-06-15 23:01:04
['2016-06-15 23:01:04'] ['2016-06-15 23:01:04']
2016-06-15 23:01:04 2016-06-15 23:01:04

View File

@ -15,11 +15,11 @@ SELECT quantilesExact(0.2)(d) FROM datetime;
SELECT quantileExactWeighted(0.2)(d, 1) FROM datetime; SELECT quantileExactWeighted(0.2)(d, 1) FROM datetime;
SELECT quantilesExactWeighted(0.2)(d, 1) FROM datetime; SELECT quantilesExactWeighted(0.2)(d, 1) FROM datetime;
SELECT quantileTiming(0.2)(d) FROM datetime; -- { serverError 43 } SELECT quantileTiming(0.2)(d) FROM datetime;
SELECT quantilesTiming(0.2)(d) FROM datetime; -- { serverError 43 } SELECT quantilesTiming(0.2)(d) FROM datetime;
SELECT quantileTimingWeighted(0.2)(d, 1) FROM datetime; -- { serverError 43 } SELECT quantileTimingWeighted(0.2)(d, 1) FROM datetime;
SELECT quantilesTimingWeighted(0.2)(d, 1) FROM datetime; -- { serverError 43 } SELECT quantilesTimingWeighted(0.2)(d, 1) FROM datetime;
SELECT quantileTDigest(0.2)(d) FROM datetime; SELECT quantileTDigest(0.2)(d) FROM datetime;
SELECT quantilesTDigest(0.2)(d) FROM datetime; SELECT quantilesTDigest(0.2)(d) FROM datetime;

View File

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