Merge pull request #153 from ludv1x/METR-23285

Fixed segfaults in quantiles* functions with empty levels set.
This commit is contained in:
alexey-milovidov 2016-10-27 19:17:10 +04:00 committed by GitHub
commit 77e3d75ca0
5 changed files with 31 additions and 0 deletions

View File

@ -233,6 +233,9 @@ public:
size_t num_levels = levels.size();
offsets_to.push_back((offsets_to.size() == 0 ? 0 : offsets_to.back()) + num_levels);
if (!num_levels)
return;
typename ColumnVector<ValueType>::Container_t & data_to = static_cast<ColumnVector<ValueType> &>(arr_to.getData()).getData();
size_t old_size = data_to.size();

View File

@ -541,6 +541,9 @@ public:
size_t size = levels.size();
offsets_to.push_back((offsets_to.size() == 0 ? 0 : offsets_to.back()) + size);
if (!size)
return;
if (returns_float)
{
typename ColumnFloat32::Container_t & data_to = static_cast<ColumnFloat32 &>(arr_to.getData()).getData();
@ -623,6 +626,9 @@ public:
size_t size = levels.size();
offsets_to.push_back((offsets_to.size() == 0 ? 0 : offsets_to.back()) + size);
if (!size)
return;
if (returns_float)
{
typename ColumnFloat32::Container_t & data_to = static_cast<ColumnFloat32 &>(arr_to.getData()).getData();

View File

@ -958,6 +958,9 @@ public:
size_t size = levels.size();
offsets_to.push_back((offsets_to.size() == 0 ? 0 : offsets_to.back()) + size);
if (!size)
return;
typename ColumnFloat32::Container_t & data_to = static_cast<ColumnFloat32 &>(arr_to.getData()).getData();
size_t old_size = data_to.size();
data_to.resize(data_to.size() + size);
@ -1021,6 +1024,9 @@ public:
size_t size = levels.size();
offsets_to.push_back((offsets_to.size() == 0 ? 0 : offsets_to.back()) + size);
if (!size)
return;
typename ColumnFloat32::Container_t & data_to = static_cast<ColumnFloat32 &>(arr_to.getData()).getData();
size_t old_size = data_to.size();
data_to.resize(data_to.size() + size);

View File

@ -0,0 +1,8 @@
[]
[]
[]
[]
[]
[]
[]
[]

View File

@ -0,0 +1,8 @@
select quantiles(number) as q from (select * from system.numbers LIMIT 1000);
select quantilesExact(number) as q from (select * from system.numbers LIMIT 1000);
select quantilesExactWeighted(number, number) as q from (select * from system.numbers LIMIT 1000);
select quantilesDeterministic(number, 10000000) as q from (select * from system.numbers LIMIT 1000);
select quantilesTiming(number) as q from (select * from system.numbers LIMIT 1000);
select quantilesTimingWeighted(number, number) as q from (select * from system.numbers LIMIT 1000);
select quantilesTDigest(number) as q from (select * from system.numbers LIMIT 1000);
select quantilesTDigestWeighted(number, number) as q from (select * from system.numbers LIMIT 1000);