我是esper的新手,我希望将数据存储在tbl_config中。这是一些esper配置文件:
config.epl
module rms.config;
create table tbl_config(
id java.math.BigDecimal primary key,
time java.math.BigDecimal
);
create schema ConfigListEvent as (
id java.math.BigDecimal,
time java.math.BigDecimal
);
@Audit
@Name("LoadConfigDataFromDBRule")
insert into ConfigListEvent
select tbl.ID as id, tbl.time as time
from ImportDataEvent,
sql: rms ['select * from T_CONFIG'] as tbl;
@Audit
@Priority(1)
@Name("DeleteConfigDataRule")
on ConfigListEvent as evt
delete from tbl_config as tbl where evt.id = tbl.id;
@Audit
@Name("InsertConfigDataRule")
on ConfigListEvent
insert into tbl_config select *;
stat.epl
module rms.stat;
uses rms.config;
@Name("Create-PaymentContext")
create window PaymentWindow.win:time(2 hour) as PaymentRequest;
@Audit
@Name("insertPaymentRequest ")
@Priority(1)
insert into PaymentWindow select * from PaymentRequest;
rule.epl
module rms.rule;
uses rms.config;
uses rms.stat;
@Audit
@Name("xxx")
@Description("check max times per IntervalTime")
on PaymentRequest as pay
select CustomUtil.getEndTime(pay.createTime,tbl_config["time"]) as startTime from PaymentWindow as payWindow;
然后系统启动时出现错误:
com.espertech.esper.epl.expression.core.ExprValidationException: Failed to validate method-chain parameter expression 'tbl_config["time"]': Incompatible type returned by a key expression for use with table 'tbl_config', the key expression '"time"' returns 'java.lang.String' but the table expects 'java.math.BigDecimal'
这让我困惑了几天,谢谢你的帮助!
答案 0 :(得分:0)
该表有一个键字段“id”,类型为BigDecimal。
然而,表达式tbl_config["time"]
提供字符串值“time”作为键而不是BigDecimal值。请尝试tbl_config[id]
,假设付款请求中有一个名为“id”的字段,其类型为BigDecimal。
config.epl中的on-delete和on-insert看起来有点尴尬,并且on-merge会使这个易于阅读的语句。