diff --git a/tests/queries/0_stateless/01656_sequence_next_node_long.sql b/tests/queries/0_stateless/01656_sequence_next_node_long.sql index d0d01e989b8..9c181f5e491 100644 --- a/tests/queries/0_stateless/01656_sequence_next_node_long.sql +++ b/tests/queries/0_stateless/01656_sequence_next_node_long.sql @@ -4,30 +4,30 @@ DROP TABLE IF EXISTS test_sequenceNextNode_Nullable; CREATE TABLE IF NOT EXISTS test_sequenceNextNode_Nullable (dt DateTime, id int, action Nullable(String)) ENGINE = MergeTree() PARTITION BY dt ORDER BY id; -INSERT INTO test_sequenceNextNode_Nullable values ('1970-01-01 09:00:01',1,'A'); -INSERT INTO test_sequenceNextNode_Nullable values ('1970-01-01 09:00:02',1,'B'); -INSERT INTO test_sequenceNextNode_Nullable values ('1970-01-01 09:00:03',1,'C'); -INSERT INTO test_sequenceNextNode_Nullable values ('1970-01-01 09:00:04',1,'D'); -INSERT INTO test_sequenceNextNode_Nullable values ('1970-01-01 09:00:01',2,'B'); -INSERT INTO test_sequenceNextNode_Nullable values ('1970-01-01 09:00:02',2,'B'); -INSERT INTO test_sequenceNextNode_Nullable values ('1970-01-01 09:00:03',2,'D'); -INSERT INTO test_sequenceNextNode_Nullable values ('1970-01-01 09:00:04',2,'C'); -INSERT INTO test_sequenceNextNode_Nullable values ('1970-01-01 09:00:01',3,'A'); -INSERT INTO test_sequenceNextNode_Nullable values ('1970-01-01 09:00:02',3,'B'); -INSERT INTO test_sequenceNextNode_Nullable values ('1970-01-01 09:00:01',4,'A'); -INSERT INTO test_sequenceNextNode_Nullable values ('1970-01-01 09:00:02',4,'A'); -INSERT INTO test_sequenceNextNode_Nullable values ('1970-01-01 09:00:03',4,'A'); -INSERT INTO test_sequenceNextNode_Nullable values ('1970-01-01 09:00:04',4,'B'); -INSERT INTO test_sequenceNextNode_Nullable values ('1970-01-01 09:00:05',4,'C'); -INSERT INTO test_sequenceNextNode_Nullable values ('1970-01-01 09:00:01',5,'A'); -INSERT INTO test_sequenceNextNode_Nullable values ('1970-01-01 09:00:02',5,'B'); -INSERT INTO test_sequenceNextNode_Nullable values ('1970-01-01 09:00:03',5,'A'); -INSERT INTO test_sequenceNextNode_Nullable values ('1970-01-01 09:00:04',5,'C'); -INSERT INTO test_sequenceNextNode_Nullable values ('1970-01-01 09:00:01',6,'A'); -INSERT INTO test_sequenceNextNode_Nullable values ('1970-01-01 09:00:02',6,'B'); -INSERT INTO test_sequenceNextNode_Nullable values ('1970-01-01 09:00:03',6,'A'); -INSERT INTO test_sequenceNextNode_Nullable values ('1970-01-01 09:00:04',6,'B'); -INSERT INTO test_sequenceNextNode_Nullable values ('1970-01-01 09:00:05',6,'C'); +INSERT INTO test_sequenceNextNode_Nullable values ('2000-01-02 09:00:01',1,'A'); +INSERT INTO test_sequenceNextNode_Nullable values ('2000-01-02 09:00:02',1,'B'); +INSERT INTO test_sequenceNextNode_Nullable values ('2000-01-02 09:00:03',1,'C'); +INSERT INTO test_sequenceNextNode_Nullable values ('2000-01-02 09:00:04',1,'D'); +INSERT INTO test_sequenceNextNode_Nullable values ('2000-01-02 09:00:01',2,'B'); +INSERT INTO test_sequenceNextNode_Nullable values ('2000-01-02 09:00:02',2,'B'); +INSERT INTO test_sequenceNextNode_Nullable values ('2000-01-02 09:00:03',2,'D'); +INSERT INTO test_sequenceNextNode_Nullable values ('2000-01-02 09:00:04',2,'C'); +INSERT INTO test_sequenceNextNode_Nullable values ('2000-01-02 09:00:01',3,'A'); +INSERT INTO test_sequenceNextNode_Nullable values ('2000-01-02 09:00:02',3,'B'); +INSERT INTO test_sequenceNextNode_Nullable values ('2000-01-02 09:00:01',4,'A'); +INSERT INTO test_sequenceNextNode_Nullable values ('2000-01-02 09:00:02',4,'A'); +INSERT INTO test_sequenceNextNode_Nullable values ('2000-01-02 09:00:03',4,'A'); +INSERT INTO test_sequenceNextNode_Nullable values ('2000-01-02 09:00:04',4,'B'); +INSERT INTO test_sequenceNextNode_Nullable values ('2000-01-02 09:00:05',4,'C'); +INSERT INTO test_sequenceNextNode_Nullable values ('2000-01-02 09:00:01',5,'A'); +INSERT INTO test_sequenceNextNode_Nullable values ('2000-01-02 09:00:02',5,'B'); +INSERT INTO test_sequenceNextNode_Nullable values ('2000-01-02 09:00:03',5,'A'); +INSERT INTO test_sequenceNextNode_Nullable values ('2000-01-02 09:00:04',5,'C'); +INSERT INTO test_sequenceNextNode_Nullable values ('2000-01-02 09:00:01',6,'A'); +INSERT INTO test_sequenceNextNode_Nullable values ('2000-01-02 09:00:02',6,'B'); +INSERT INTO test_sequenceNextNode_Nullable values ('2000-01-02 09:00:03',6,'A'); +INSERT INTO test_sequenceNextNode_Nullable values ('2000-01-02 09:00:04',6,'B'); +INSERT INTO test_sequenceNextNode_Nullable values ('2000-01-02 09:00:05',6,'C'); SELECT '(forward, head, A)', id, sequenceNextNode('forward', 'head')(dt, action, 1, action = 'A') AS next_node FROM test_sequenceNextNode_Nullable GROUP BY id ORDER BY id; SELECT '(forward, head, B)', id, sequenceNextNode('forward', 'head')(dt, action, 1, action = 'B') AS next_node FROM test_sequenceNextNode_Nullable GROUP BY id ORDER BY id; @@ -50,11 +50,11 @@ SELECT '(forward, head, B->A->A)', id, sequenceNextNode('forward', 'head')(dt, a SELECT '(backward, tail, A->A->B)', id, sequenceNextNode('backward', 'tail')(dt, action, 1, action = 'A', action = 'A', action = 'B') AS next_node FROM test_sequenceNextNode_Nullable GROUP BY id ORDER BY id; SELECT '(backward, tail, B->A->A)', id, sequenceNextNode('backward', 'tail')(dt, action, 1, action = 'B', action = 'A', action = 'A') AS next_node FROM test_sequenceNextNode_Nullable GROUP BY id ORDER BY id; -INSERT INTO test_sequenceNextNode_Nullable values ('1970-01-01 09:00:01',10,'A'); -INSERT INTO test_sequenceNextNode_Nullable values ('1970-01-01 09:00:02',10,'B'); -INSERT INTO test_sequenceNextNode_Nullable values ('1970-01-01 09:00:02',10,NULL); -INSERT INTO test_sequenceNextNode_Nullable values ('1970-01-01 09:00:03',10,'C'); -INSERT INTO test_sequenceNextNode_Nullable values ('1970-01-01 09:00:04',10,'D'); +INSERT INTO test_sequenceNextNode_Nullable values ('2000-01-02 09:00:01',10,'A'); +INSERT INTO test_sequenceNextNode_Nullable values ('2000-01-02 09:00:02',10,'B'); +INSERT INTO test_sequenceNextNode_Nullable values ('2000-01-02 09:00:02',10,NULL); +INSERT INTO test_sequenceNextNode_Nullable values ('2000-01-02 09:00:03',10,'C'); +INSERT INTO test_sequenceNextNode_Nullable values ('2000-01-02 09:00:04',10,'D'); SELECT '(forward, head, A) id >= 10', id, sequenceNextNode('forward', 'head')(dt, action, 1, action = 'A') AS next_node FROM test_sequenceNextNode_Nullable WHERE id >= 10 GROUP BY id ORDER BY id; SELECT '(forward, head, A) id >= 10', id, sequenceNextNode('forward', 'head')(dt, action, 1, action = 'A', action = 'B') AS next_node FROM test_sequenceNextNode_Nullable WHERE id >= 10 GROUP BY id ORDER BY id; @@ -63,10 +63,10 @@ SELECT '(forward, head, A) id >= 10', id, sequenceNextNode('backward', 'tail')(d SELECT '(backward, tail, A) id >= 10', id, sequenceNextNode('backward', 'tail')(dt, action, 1, action = 'D', action = 'C') AS next_node FROM test_sequenceNextNode_Nullable WHERE id >= 10 GROUP BY id ORDER BY id; SELECT '(backward, tail, A) id >= 10', id, sequenceNextNode('backward', 'tail')(dt, action, 1, action = 'D', action = 'C', action = 'B') AS next_node FROM test_sequenceNextNode_Nullable WHERE id >= 10 GROUP BY id ORDER BY id; -INSERT INTO test_sequenceNextNode_Nullable values ('1970-01-01 09:00:01',11,'A'); -INSERT INTO test_sequenceNextNode_Nullable values ('1970-01-01 09:00:01',11,'B'); -INSERT INTO test_sequenceNextNode_Nullable values ('1970-01-01 09:00:01',11,'C'); -INSERT INTO test_sequenceNextNode_Nullable values ('1970-01-01 09:00:01',11,'D'); +INSERT INTO test_sequenceNextNode_Nullable values ('2000-01-02 09:00:01',11,'A'); +INSERT INTO test_sequenceNextNode_Nullable values ('2000-01-02 09:00:01',11,'B'); +INSERT INTO test_sequenceNextNode_Nullable values ('2000-01-02 09:00:01',11,'C'); +INSERT INTO test_sequenceNextNode_Nullable values ('2000-01-02 09:00:01',11,'D'); SELECT '(0, A) id = 11', count() FROM (SELECT id, sequenceNextNode('forward', 'head')(dt, action, 1, action = 'A') AS next_node FROM test_sequenceNextNode_Nullable WHERE id = 11 GROUP BY id HAVING next_node = 'B'); SELECT '(0, C) id = 11', count() FROM (SELECT id, sequenceNextNode('forward', 'head')(dt, action, 1, action = 'C') AS next_node FROM test_sequenceNextNode_Nullable WHERE id = 11 GROUP BY id HAVING next_node = 'D'); @@ -100,30 +100,30 @@ DROP TABLE IF EXISTS test_sequenceNextNode; CREATE TABLE IF NOT EXISTS test_sequenceNextNode (dt DateTime, id int, action String) ENGINE = MergeTree() PARTITION BY dt ORDER BY id; -INSERT INTO test_sequenceNextNode values ('1970-01-01 09:00:01',1,'A'); -INSERT INTO test_sequenceNextNode values ('1970-01-01 09:00:02',1,'B'); -INSERT INTO test_sequenceNextNode values ('1970-01-01 09:00:03',1,'C'); -INSERT INTO test_sequenceNextNode values ('1970-01-01 09:00:04',1,'D'); -INSERT INTO test_sequenceNextNode values ('1970-01-01 09:00:01',2,'B'); -INSERT INTO test_sequenceNextNode values ('1970-01-01 09:00:02',2,'B'); -INSERT INTO test_sequenceNextNode values ('1970-01-01 09:00:03',2,'D'); -INSERT INTO test_sequenceNextNode values ('1970-01-01 09:00:04',2,'C'); -INSERT INTO test_sequenceNextNode values ('1970-01-01 09:00:01',3,'A'); -INSERT INTO test_sequenceNextNode values ('1970-01-01 09:00:02',3,'B'); -INSERT INTO test_sequenceNextNode values ('1970-01-01 09:00:01',4,'A'); -INSERT INTO test_sequenceNextNode values ('1970-01-01 09:00:02',4,'A'); -INSERT INTO test_sequenceNextNode values ('1970-01-01 09:00:03',4,'A'); -INSERT INTO test_sequenceNextNode values ('1970-01-01 09:00:04',4,'B'); -INSERT INTO test_sequenceNextNode values ('1970-01-01 09:00:05',4,'C'); -INSERT INTO test_sequenceNextNode values ('1970-01-01 09:00:01',5,'A'); -INSERT INTO test_sequenceNextNode values ('1970-01-01 09:00:02',5,'B'); -INSERT INTO test_sequenceNextNode values ('1970-01-01 09:00:03',5,'A'); -INSERT INTO test_sequenceNextNode values ('1970-01-01 09:00:04',5,'C'); -INSERT INTO test_sequenceNextNode values ('1970-01-01 09:00:01',6,'A'); -INSERT INTO test_sequenceNextNode values ('1970-01-01 09:00:02',6,'B'); -INSERT INTO test_sequenceNextNode values ('1970-01-01 09:00:03',6,'A'); -INSERT INTO test_sequenceNextNode values ('1970-01-01 09:00:04',6,'B'); -INSERT INTO test_sequenceNextNode values ('1970-01-01 09:00:05',6,'C'); +INSERT INTO test_sequenceNextNode values ('2000-01-02 09:00:01',1,'A'); +INSERT INTO test_sequenceNextNode values ('2000-01-02 09:00:02',1,'B'); +INSERT INTO test_sequenceNextNode values ('2000-01-02 09:00:03',1,'C'); +INSERT INTO test_sequenceNextNode values ('2000-01-02 09:00:04',1,'D'); +INSERT INTO test_sequenceNextNode values ('2000-01-02 09:00:01',2,'B'); +INSERT INTO test_sequenceNextNode values ('2000-01-02 09:00:02',2,'B'); +INSERT INTO test_sequenceNextNode values ('2000-01-02 09:00:03',2,'D'); +INSERT INTO test_sequenceNextNode values ('2000-01-02 09:00:04',2,'C'); +INSERT INTO test_sequenceNextNode values ('2000-01-02 09:00:01',3,'A'); +INSERT INTO test_sequenceNextNode values ('2000-01-02 09:00:02',3,'B'); +INSERT INTO test_sequenceNextNode values ('2000-01-02 09:00:01',4,'A'); +INSERT INTO test_sequenceNextNode values ('2000-01-02 09:00:02',4,'A'); +INSERT INTO test_sequenceNextNode values ('2000-01-02 09:00:03',4,'A'); +INSERT INTO test_sequenceNextNode values ('2000-01-02 09:00:04',4,'B'); +INSERT INTO test_sequenceNextNode values ('2000-01-02 09:00:05',4,'C'); +INSERT INTO test_sequenceNextNode values ('2000-01-02 09:00:01',5,'A'); +INSERT INTO test_sequenceNextNode values ('2000-01-02 09:00:02',5,'B'); +INSERT INTO test_sequenceNextNode values ('2000-01-02 09:00:03',5,'A'); +INSERT INTO test_sequenceNextNode values ('2000-01-02 09:00:04',5,'C'); +INSERT INTO test_sequenceNextNode values ('2000-01-02 09:00:01',6,'A'); +INSERT INTO test_sequenceNextNode values ('2000-01-02 09:00:02',6,'B'); +INSERT INTO test_sequenceNextNode values ('2000-01-02 09:00:03',6,'A'); +INSERT INTO test_sequenceNextNode values ('2000-01-02 09:00:04',6,'B'); +INSERT INTO test_sequenceNextNode values ('2000-01-02 09:00:05',6,'C'); SELECT '(forward, head, A)', id, sequenceNextNode('forward', 'head')(dt, action, 1, action = 'A') AS next_node FROM test_sequenceNextNode GROUP BY id ORDER BY id; SELECT '(forward, head, B)', id, sequenceNextNode('forward', 'head')(dt, action, 1, action = 'B') AS next_node FROM test_sequenceNextNode GROUP BY id ORDER BY id; @@ -146,10 +146,10 @@ SELECT '(forward, head, B->A->A)', id, sequenceNextNode('forward', 'head')(dt, a SELECT '(backward, tail, A->A->B)', id, sequenceNextNode('backward', 'tail')(dt, action, 1, action = 'A', action = 'A', action = 'B') AS next_node FROM test_sequenceNextNode GROUP BY id ORDER BY id; SELECT '(backward, tail, B->A->A)', id, sequenceNextNode('backward', 'tail')(dt, action, 1, action = 'B', action = 'A', action = 'A') AS next_node FROM test_sequenceNextNode GROUP BY id ORDER BY id; -INSERT INTO test_sequenceNextNode values ('1970-01-01 09:00:01',10,'A'); -INSERT INTO test_sequenceNextNode values ('1970-01-01 09:00:02',10,'B'); -INSERT INTO test_sequenceNextNode values ('1970-01-01 09:00:03',10,'C'); -INSERT INTO test_sequenceNextNode values ('1970-01-01 09:00:04',10,'D'); +INSERT INTO test_sequenceNextNode values ('2000-01-02 09:00:01',10,'A'); +INSERT INTO test_sequenceNextNode values ('2000-01-02 09:00:02',10,'B'); +INSERT INTO test_sequenceNextNode values ('2000-01-02 09:00:03',10,'C'); +INSERT INTO test_sequenceNextNode values ('2000-01-02 09:00:04',10,'D'); SELECT '(forward, head, A) id >= 10', id, sequenceNextNode('forward', 'head')(dt, action, 1, action = 'A') AS next_node FROM test_sequenceNextNode WHERE id >= 10 GROUP BY id ORDER BY id; SELECT '(forward, head, A) id >= 10', id, sequenceNextNode('forward', 'head')(dt, action, 1, action = 'A', action = 'B') AS next_node FROM test_sequenceNextNode WHERE id >= 10 GROUP BY id ORDER BY id; @@ -158,10 +158,10 @@ SELECT '(forward, head, A) id >= 10', id, sequenceNextNode('backward', 'tail')(d SELECT '(backward, tail, A) id >= 10', id, sequenceNextNode('backward', 'tail')(dt, action, 1, action = 'D', action = 'C') AS next_node FROM test_sequenceNextNode WHERE id >= 10 GROUP BY id ORDER BY id; SELECT '(backward, tail, A) id >= 10', id, sequenceNextNode('backward', 'tail')(dt, action, 1, action = 'D', action = 'C', action = 'B') AS next_node FROM test_sequenceNextNode WHERE id >= 10 GROUP BY id ORDER BY id; -INSERT INTO test_sequenceNextNode values ('1970-01-01 09:00:01',11,'A'); -INSERT INTO test_sequenceNextNode values ('1970-01-01 09:00:01',11,'B'); -INSERT INTO test_sequenceNextNode values ('1970-01-01 09:00:01',11,'C'); -INSERT INTO test_sequenceNextNode values ('1970-01-01 09:00:01',11,'D'); +INSERT INTO test_sequenceNextNode values ('2000-01-02 09:00:01',11,'A'); +INSERT INTO test_sequenceNextNode values ('2000-01-02 09:00:01',11,'B'); +INSERT INTO test_sequenceNextNode values ('2000-01-02 09:00:01',11,'C'); +INSERT INTO test_sequenceNextNode values ('2000-01-02 09:00:01',11,'D'); SELECT '(0, A) id = 11', count() FROM (SELECT id, sequenceNextNode('forward', 'head')(dt, action, 1, action = 'A') AS next_node FROM test_sequenceNextNode WHERE id = 11 GROUP BY id HAVING next_node = 'B'); SELECT '(0, C) id = 11', count() FROM (SELECT id, sequenceNextNode('forward', 'head')(dt, action, 1, action = 'C') AS next_node FROM test_sequenceNextNode WHERE id = 11 GROUP BY id HAVING next_node = 'D'); @@ -189,8 +189,8 @@ SELECT '(backward, first_match, B->B)', id, sequenceNextNode('backward', 'first_ SELECT '(max_args)', id, sequenceNextNode('forward', 'head')(dt, action, 1, action = '0', action = '1', action = '2', action = '3', action = '4', action = '5', action = '6', action = '7', action = '8', action = '9', action = '10', action = '11', action = '12', action = '13', action = '14', action = '15', action = '16', action = '17', action = '18', action = '19', action = '20', action = '21', action = '22', action = '23', action = '24', action = '25', action = '26', action = '27', action = '28', action = '29', action = '30', action = '31', action = '32', action = '33', action = '34', action = '35', action = '36', action = '37', action = '38', action = '39', action = '40', action = '41', action = '42', action = '43', action = '44', action = '45', action = '46', action = '47', action = '48', action = '49', action = '50', action = '51', action = '52', action = '53', action = '54', action = '55', action = '56', action = '57', action = '58', action = '59', action = '60', action = '61', action = '62', action = '63') from test_sequenceNextNode GROUP BY id ORDER BY id; -INSERT INTO test_sequenceNextNode values ('1970-01-01 09:00:01',12,'A'); -INSERT INTO test_sequenceNextNode values ('1970-01-01 09:00:01',12,'A'); +INSERT INTO test_sequenceNextNode values ('2000-01-02 09:00:01',12,'A'); +INSERT INTO test_sequenceNextNode values ('2000-01-02 09:00:01',12,'A'); SELECT '(forward, head, A) id = 12', sequenceNextNode('forward', 'head')(dt, action, 1, action = 'A') AS next_node FROM test_sequenceNextNode WHERE id = 12; @@ -200,18 +200,18 @@ DROP TABLE IF EXISTS test_base_condition; CREATE TABLE IF NOT EXISTS test_base_condition (dt DateTime, id int, action String, referrer String) ENGINE = MergeTree() PARTITION BY dt ORDER BY id; -INSERT INTO test_base_condition values ('1970-01-01 09:00:01',1,'A','1'); -INSERT INTO test_base_condition values ('1970-01-01 09:00:02',1,'B','2'); -INSERT INTO test_base_condition values ('1970-01-01 09:00:03',1,'C','3'); -INSERT INTO test_base_condition values ('1970-01-01 09:00:04',1,'D','4'); -INSERT INTO test_base_condition values ('1970-01-01 09:00:01',2,'D','4'); -INSERT INTO test_base_condition values ('1970-01-01 09:00:02',2,'C','3'); -INSERT INTO test_base_condition values ('1970-01-01 09:00:03',2,'B','2'); -INSERT INTO test_base_condition values ('1970-01-01 09:00:04',2,'A','1'); -INSERT INTO test_base_condition values ('1970-01-01 09:00:01',3,'B','10'); -INSERT INTO test_base_condition values ('1970-01-01 09:00:02',3,'B','2'); -INSERT INTO test_base_condition values ('1970-01-01 09:00:03',3,'D','3'); -INSERT INTO test_base_condition values ('1970-01-01 09:00:04',3,'C','4'); +INSERT INTO test_base_condition values ('2000-01-02 09:00:01',1,'A','1'); +INSERT INTO test_base_condition values ('2000-01-02 09:00:02',1,'B','2'); +INSERT INTO test_base_condition values ('2000-01-02 09:00:03',1,'C','3'); +INSERT INTO test_base_condition values ('2000-01-02 09:00:04',1,'D','4'); +INSERT INTO test_base_condition values ('2000-01-02 09:00:01',2,'D','4'); +INSERT INTO test_base_condition values ('2000-01-02 09:00:02',2,'C','3'); +INSERT INTO test_base_condition values ('2000-01-02 09:00:03',2,'B','2'); +INSERT INTO test_base_condition values ('2000-01-02 09:00:04',2,'A','1'); +INSERT INTO test_base_condition values ('2000-01-02 09:00:01',3,'B','10'); +INSERT INTO test_base_condition values ('2000-01-02 09:00:02',3,'B','2'); +INSERT INTO test_base_condition values ('2000-01-02 09:00:03',3,'D','3'); +INSERT INTO test_base_condition values ('2000-01-02 09:00:04',3,'C','4'); SELECT '(forward, head, 1)', id, sequenceNextNode('forward', 'head')(dt, action, referrer = '1') AS next_node FROM test_base_condition GROUP BY id ORDER BY id; SELECT '(forward, head, 1, A)', id, sequenceNextNode('forward', 'head')(dt, action, referrer = '1', action = 'A') AS next_node FROM test_base_condition GROUP BY id ORDER BY id;