更新或插入siddhi文件以忽略不可用的字段,而不是更新所有字段

问题描述 投票:0回答:1

我有一个siddhi文件,可从kafka主题中读取并写入数据库。

@store(type='rdbms' , datasource='WSO2_CLUSTER',table.name='sample_table')
define table sample_table(col1 string, col2 string, corr_id string);


from kafkaInputMetricCorr
select col1, col2, corr_id
update or insert into sample_table 
on sample_table.corr_id == corr_id;

当我使用此“更新或插入”功能时,即使该字段在Kafka事件中不可用,它也会更新所有字段(col1,col2,corr_id)。当kafka消息包含“ col1和corr_id”时,我只希望更新col1和corr_id。现在发生的是,它将col2更新为null。我什至尝试更改为

select *

希望仅在Kafka事件中可用的字段将被更新。但是它不起作用。请帮忙。谢谢。

siddhi
1个回答
0
投票

如果您不想更新所有字段,则必须使用set子句,https://siddhi.io/en/v5.1/docs/query-guide/#update-or-insert

from kafkaInputMetricCorr
select col1, col2, corr_id
update or insert into sample_table 
set sample_table.col1 = col1, sample_table.corr_id = corr_id
on sample_table.corr_id == corr_id;
© www.soinside.com 2019 - 2024. All rights reserved.