Fix a corner case of windowFunnel with 'strict_order'

This commit is contained in:
philip.han 2020-03-30 19:35:54 +09:00
parent d8ff25d364
commit 210024cd3a
3 changed files with 11 additions and 0 deletions

View File

@ -186,6 +186,14 @@ private:
{ {
return event_idx + 1; return event_idx + 1;
} }
else if (strict_order && first_event && events_timestamp[event_idx - 1] == -1)
{
for (size_t event = 0; event < events_timestamp.size(); ++event)
{
if (events_timestamp[event] == -1)
return event;
}
}
else if (events_timestamp[event_idx - 1] >= 0 && timestamp <= events_timestamp[event_idx - 1] + window) else if (events_timestamp[event_idx - 1] >= 0 && timestamp <= events_timestamp[event_idx - 1] + window)
{ {
events_timestamp[event_idx] = events_timestamp[event_idx - 1]; events_timestamp[event_idx] = events_timestamp[event_idx - 1];

View File

@ -36,6 +36,7 @@
[4, 2] [4, 2]
[5, 2] [5, 2]
[6, 1] [6, 1]
[7, 1]
[1, 2] [1, 2]
[2, 2] [2, 2]
[3, 0] [3, 0]

View File

@ -63,6 +63,8 @@ insert into funnel_test_strict_order values (1, 6, 'c') (2, 6, 'c') (3, 6, 'b')
select user, windowFunnel(86400)(dt, event='a', event='b', event='c') as s from funnel_test_strict_order group by user order by user format JSONCompactEachRow; select user, windowFunnel(86400)(dt, event='a', event='b', event='c') as s from funnel_test_strict_order group by user order by user format JSONCompactEachRow;
select user, windowFunnel(86400, 'strict_order')(dt, event='a', event='b', event='c') as s from funnel_test_strict_order group by user order by user format JSONCompactEachRow; select user, windowFunnel(86400, 'strict_order')(dt, event='a', event='b', event='c') as s from funnel_test_strict_order group by user order by user format JSONCompactEachRow;
select user, windowFunnel(86400, 'strict', 'strict_order')(dt, event='a', event='b', event='c') as s from funnel_test_strict_order group by user order by user format JSONCompactEachRow; select user, windowFunnel(86400, 'strict', 'strict_order')(dt, event='a', event='b', event='c') as s from funnel_test_strict_order group by user order by user format JSONCompactEachRow;
insert into funnel_test_strict_order values (1, 7, 'a') (2, 7, 'c') (3, 7, 'b');
select user, windowFunnel(10, 'strict_order')(dt, event = 'a', event = 'b', event = 'c') as s from funnel_test_strict_order where user = 7 group by user format JSONCompactEachRow;
drop table funnel_test_strict_order; drop table funnel_test_strict_order;
drop table if exists funnel_test_non_null; drop table if exists funnel_test_non_null;