我可以在创建继续视图时使用exists子查询吗?

时间:2018-06-11 16:37:43

标签: pipelinedb

我想创建一个简历,如下所示: CREATE CONTINUOUS view v_struct1_abonormal AS( select data_value from stream_struct1 where exists( select 1 from stream_struct1 s,jsonb_each_text(data_value->'metrics') j where nullif(j.value,'')::numeric >100000 or nullif(j.value,'')::numeric <0) ) ; 当我将数据插入流时,将不会捕获等于“-1”的值。

INSERT INTO stream_struct1 VALUES('{"data_time":"2018-05-23 18:10:00","mn_code":"06057581403003","metrics":{"CW011":"5.00000","ZJ101":"-1","ZJ011":"5.00000"}}');

但是,如果我将数据插入表中,则以下SQL可以正常工作。 select data_value from struct1 where exists( select 1 from struct1 s,jsonb_each_text(data_value->'metrics') j where nullif(j.value,'')::numeric >100000 or nullif(j.value,'')::numeric <0);

CV是否支持exists子查询?

BTW:我的JSON数据结构如下: {
"mn_code":"06057582401042", "data_time":"20180228110759", "metrics":{ "lg":null, "lgd":null, "lt":null, "ltd":4, "spd":0, "bv":12.00, "kpm25":35, "kpm10":47, "kb03":51, "kw01":24.84, "ks01":63.42, "kp01":1015.27 }, "status":{ "lg":"N", "lgd":"N", "lt":"N", "ltd":"N", "spd":"N", "bv":"N", "kpm25":"N", "kpm10":"N", "kb03":"N", "kw01":"N", "ks01":"N", "kp01":"N" }, "tag":{ "dev":"B280V3", "USAGE":"001" } }

create stream chr.stream_struct1 ( data_value jsonb );

0 个答案:

没有答案