Added proper test for merging of "histogram" aggregate function states

This commit is contained in:
Alexey Milovidov 2019-03-23 05:47:45 +03:00
parent 1fdbb11bfb
commit d3062924c8
4 changed files with 8 additions and 36 deletions

View File

@ -0,0 +1,6 @@
0 55 101
55 117 97
117 199 92
0 55 101
55 117 97
117 199 92

View File

@ -0,0 +1,2 @@
WITH arrayJoin(finalizeAggregation((SELECT histogramState(3)(number) FROM numbers(10, 190)) + (SELECT histogramState(3)(number) FROM numbers(0, 100)))) AS hist SELECT round(hist.1) AS l, round(hist.2) AS r, round(hist.3) AS cnt;
WITH arrayJoin(finalizeAggregation((SELECT histogramState(3)(number) FROM numbers(0, 100)) + (SELECT histogramState(3)(number) FROM numbers(10, 190)))) AS hist SELECT round(hist.1) AS l, round(hist.2) AS r, round(hist.3) AS cnt;

View File

@ -1,34 +0,0 @@
create table test.test_histogram (a Int32)
ENGINE = Memory
--127.0.0.1
insert into test.test_histogram (a) SELECT * FROM numbers(10, 190)
--127.0.0.2
insert into test.test_histogram (a) SELECT * FROM numbers(0, 100)
--make sure upper_bound=199
--when merging AggregationState in both 1,2 and 2,1 order
with
histogram(3)(a) AS hst,
arrayJoin(hst) AS hst_array
select
round(hst_array.2) AS upper_bound
from remote('127.0.0.{1,2}', 'test', 'test_histogram')
having upper_bound = 199
order by upper_bound desc
limit 1
with
histogram(3)(a) AS hst,
arrayJoin(hst) AS hst_array
select
round(hst_array.2) AS upper_bound
from remote('127.0.0.{2,1}', 'test', 'test_histogram')
having upper_bound = 199
order by upper_bound desc
limit 1
drop table test.test_histogram