fix as comment

This commit is contained in:
wangtao.2077 2024-04-08 14:38:32 +08:00 committed by Alexey Milovidov
parent 347c24e6f3
commit c4062de047
5 changed files with 19 additions and 10 deletions

View File

@ -65,6 +65,8 @@ struct AggregateFunctionBoundingRatioData
}
else if (other.empty)
{
// if other.empty = true, other.x/other.y may be uninitialized values,
// so don't use them to update this->state
}
else
{

View File

@ -1,6 +1,5 @@
1
1
1
1.5
1.5
1.5

View File

@ -1,19 +1,10 @@
drop table if exists rate_test;
drop table if exists rate_test2;
create table rate_test (timestamp UInt32, event UInt32) engine=Memory;
insert into rate_test values (0,1000),(1,1001),(2,1002),(3,1003),(4,1004),(5,1005),(6,1006),(7,1007),(8,1008);
select 1.0 = boundingRatio(timestamp, event) from rate_test;
create table rate_test2 (timestamp UInt32, event UInt32) engine=Memory;
SELECT boundingRatioMerge(state) FROM (
select boundingRatioState(timestamp, event) as state from rate_test
UNION ALL
SELECT boundingRatioState(timestamp, event) FROM rate_test2 WHERE 1=0
);
drop table if exists rate_test2;
create table rate_test2 (uid UInt32 default 1,timestamp DateTime, event UInt32) engine=Memory;
insert into rate_test2(timestamp, event) values ('2018-01-01 01:01:01',1001),('2018-01-01 01:01:02',1002),('2018-01-01 01:01:03',1003),('2018-01-01 01:01:04',1004),('2018-01-01 01:01:05',1005),('2018-01-01 01:01:06',1006),('2018-01-01 01:01:07',1007),('2018-01-01 01:01:08',1008);

View File

@ -0,0 +1,16 @@
drop table if exists rate_test;
drop table if exists rate_test2;
create table rate_test (timestamp UInt32, event UInt32) engine=Memory;
insert into rate_test values (0,1000),(1,1001),(2,1002),(3,1003),(4,1004),(5,1005),(6,1006),(7,1007),(8,1008);
create table rate_test2 (timestamp UInt32, event UInt32) engine=Memory;
SELECT boundingRatioMerge(state) FROM (
select boundingRatioState(timestamp, event) as state from rate_test
UNION ALL
SELECT boundingRatioState(timestamp, event) FROM rate_test2 WHERE 1=0
);
drop table if exists rate_test;
drop table if exists rate_test2;