ClickHouse/dbms/tests/queries/0_stateless/00823_sequence_match_dfa.sql

37 lines
1.0 KiB
MySQL
Raw Normal View History

2019-01-16 19:24:21 +00:00
-- this test cannot pass without the new DFA matching algorithm of sequenceMatch
DROP TABLE IF EXISTS sequence;
2019-01-16 19:24:21 +00:00
CREATE TABLE sequence
2019-01-16 19:24:21 +00:00
(
userID UInt64,
2019-05-20 04:31:52 +00:00
eventType Enum8('A' = 1, 'B' = 2, 'C' = 3, 'D' = 4),
2019-01-16 19:24:21 +00:00
EventTime UInt64
)
ENGINE = Memory;
INSERT INTO sequence SELECT 1, number = 0 ? 'A' : (number < 1000000 ? 'B' : 'C'), number FROM numbers(1000001);
2019-05-20 04:31:52 +00:00
INSERT INTO sequence SELECT 1, 'D', 1e14;
2019-01-16 19:24:21 +00:00
SELECT 'ABC'
FROM sequence
2019-01-16 19:24:21 +00:00
GROUP BY userID
HAVING sequenceMatch('(?1).*(?2).*(?3)')(toDateTime(EventTime), eventType = 'A', eventType = 'B', eventType = 'C');
SELECT 'ABA'
FROM sequence
2019-01-16 19:24:21 +00:00
GROUP BY userID
HAVING sequenceMatch('(?1).*(?2).*(?3)')(toDateTime(EventTime), eventType = 'A', eventType = 'B', eventType = 'A');
SELECT 'ABBC'
FROM sequence
GROUP BY userID
HAVING sequenceMatch('(?1).*(?2).*(?3).*(?4)')(EventTime, eventType = 'A', eventType = 'B', eventType = 'B',eventType = 'C');
2019-05-20 04:31:52 +00:00
SELECT 'CD'
FROM sequence
GROUP BY userID
2019-05-20 04:31:52 +00:00
HAVING sequenceMatch('(?1)(?t>=10000000000000)(?2)')(EventTime, eventType = 'C', eventType = 'D');
DROP TABLE sequence;