0

我需要通过检查条件为流中的特定属性分配一个值。

我该怎么做?

例如

如果一个人的名字是“约翰”,我需要将他的名字修改为“彼得”并插入另一个流,我该怎么做?

from myStream [name == 'John']
select *
insert into outStream;
4

1 回答 1

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}

请参阅Siddhi 中的“查询投影”功能。检查操作:'Introducing the default value'

于 2015-11-28T17:20:41.603 回答