我正在使用 PipelineDB 0.9.7u3
我玩了一些连续视图输出流,看看我是否可以通过一些更新获得新的连续视图。
这是我的测试用例。
CREATE STREAM stream_test(ticketid text, val int, status text);
-- simple continuous view on stream_test
CREATE CONTINUOUS VIEW cv_test AS
SELECT
ticketid,
min(val) as v0,
keyed_min(val, status) as v0_status
FROM stream_test
GROUP BY ticketid;
-- continuous view to keep cv_test's updates and insertions
CREATE CONTINUOUS VIEW cv_test_upin AS
SELECT
(new).ticketid,
(old).v0 as oldV0,
(old).v0_status as oldV0Status,
(new).v0 as newV0,
(new).v0_status as newV0Status
FROM output_of('cv_test')
-- continuous view to keep just some cv_test's updates
CREATE CONTINUOUS VIEW cv_test_up AS
SELECT
(new).ticketid,
(old).v0 as oldV0,
(old).v0_status as oldV0Status,
(new).v0 as newV0,
(new).v0_status as newV0Status
FROM output_of('cv_test')
WHERE (old).v0 != (new).v0;
让我们放一些数据。
INSERT INTO stream_test VALUES
('t1', 124, 'open'),
('t2', 190, 'pending')
正如预期的那样:
select * from cv_test;
"t2";190;"待定"
"t1";124;"打开"
select * from cv_test_upin;
"t2";;"";190;"待定"
"t1";;"";124;"打开"
select * from cv_test_up;
然后,一些更新。
INSERT INTO stream_test VALUES
('t2', 160, 'waiting'),
('t1', 100, 'pending')
正如预期的那样:
select * from cv_test;
"t2";160;"等待"
"t1";100;"待定"
select * from cv_test_upin;
"t2";;"";190;"待定"
"t1";;"";124;"打开"
“t2”;190;“待定”;160;“等待”
“t1”;124;“打开”;100;“待定”
select * from cv_test_up;
“t2”;190;“待定”;160;“等待”
“t1”;124;“打开”;100;“待定”
现在,一些新数据和一些更新。
INSERT INTO stream_test VALUES
('t2', 90, 'spam'),
('t3', 140, 'open'),
('t1', 80, 'closed')
select * from cv_test;
按预期返回,但select * from cv_test_upin;
没有。
...
“t2”;160;“等待”;90;“垃圾邮件”
"t3";;"";140;"打开"
“t1”;80;“关闭”;80;“关闭”
我预计最后一个“t1”是"t1";100;"pending";80;"closed"
错误或预期行为?
谢谢。