diff --git a/tests/queries/0_stateless/01646_fix_window_funnel_inconistency.reference b/tests/queries/0_stateless/01646_fix_window_funnel_inconistency.reference new file mode 100644 index 00000000000..3b39d6021a2 --- /dev/null +++ b/tests/queries/0_stateless/01646_fix_window_funnel_inconistency.reference @@ -0,0 +1,3 @@ +2 1 +--- +2 1 diff --git a/tests/queries/0_stateless/01646_fix_window_funnel_inconistency.sql b/tests/queries/0_stateless/01646_fix_window_funnel_inconistency.sql new file mode 100644 index 00000000000..51f599a2b09 --- /dev/null +++ b/tests/queries/0_stateless/01646_fix_window_funnel_inconistency.sql @@ -0,0 +1,49 @@ +DROP TABLE IF EXISTS trend; +CREATE TABLE trend +( + `event_date` Date, + `user_id` Int32, + `timestamp` DateTime, + `eventID` Int32, + `product` String +) +ENGINE = MergeTree() +PARTITION BY toYYYYMM(event_date) +ORDER BY user_id; + +insert into trend values ('2019-01-28', 1, '2019-01-29 10:00:00', 1004, 'phone') ('2019-01-28', 1, '2019-01-29 10:00:00', 1003, 'phone') ('2019-01-28', 1, '2019-01-28 10:00:00', 1002, 'phone'); + +SELECT + level, + count() AS c +FROM +( + SELECT + user_id, + windowFunnel(6048000000000000)(timestamp, eventID = 1004, eventID = 1003, eventID = 1002) AS level + FROM trend + GROUP BY user_id +) +GROUP BY level +ORDER BY level ASC; + +SELECT '---'; + +TRUNCATE TABLE trend; +insert into trend values ('2019-01-28', 1, '2019-01-29 10:00:00', 1003, 'phone') ('2019-01-28', 1, '2019-01-29 10:00:00', 1004, 'phone') ('2019-01-28', 1, '2019-01-28 10:00:00', 1002, 'phone'); + +SELECT + level, + count() AS c +FROM +( + SELECT + user_id, + windowFunnel(6048000000000000)(timestamp, eventID = 1004, eventID = 1003, eventID = 1002) AS level + FROM trend + GROUP BY user_id +) +GROUP BY level +ORDER BY level ASC; + +DROP TABLE trend;