我需要通过检查条件为流中的特定属性赋值。
我该怎么做?
例如
如果一个人的姓名是' John'我需要将他的名字修改为彼得'并插入另一个流,我该怎么做?
from myStream [name == 'John']
select *
insert into outStream;
答案 0 :(得分:0)
define stream myStream (name string, attribute1 int, attribute2 bool);
from myStream [name == 'John'] --This filter matches any event with name equal to 'John'
select "Peter" as name, attribute1, attribute2 --Replaces the current name with 'Peter'
insert into outStream;
示例1
输入:
{Dilini, 123, true}
输出:
(没有输出,因为名称不满足过滤条件,name ==' John')
示例2
输入:
{John, 123, true}
输出:
{Peter, 123, true}
参考'Query Projection' capabilities in Siddhi。检查操作:'介绍默认值' 。