In WSO2 CEP 3.0.0. I experienced some confusing behavior with attributes of double type.
Assume the following siddhi script:
define stream LongStream LongAttr1 long, LongAttr2 long;
define stream DoubleStream DoubleAttr1 double;
from LongStream
select (LongAttr1/LongAttr2) as DoubleAttr1
insert into DoubleStream;
from DoubleStream[DoubleAttr1 > 0.75]
...
In this script the insertion of DoubleAttr1 in DoubleStream is working, giving well a floating value with decimals. But the filter afterwards is raising a casting exception.
ERROR - {QuerySelector} Input event attribute type java.lang.Double cannot be cast to java.lang.Long type defined in the stream definition!
java.lang.ClassCastException: java.lang.Double cannot be cast to java.lang.Long at org.wso2.siddhi.core.executor.conditon.compare.greater_than_equal.GreaterThanEqualCompareConditionExecutorLongDouble.process(GreaterThanEqualCompareConditionExecutorLongDouble.java:34)
This is rather confusing it seems that the DoubleAttr1 is considered as a long?
If I calculate DoubleAttr1 as:
convert(LongAttr1/LongAttr2, double)
or
(LongAttr1 * 100.0) / (LongAttr2 * 100.0)
the exception is not raised anymore. I found this behavior quite confusing and I think it should be prevented or corrected in further releases. What is your opinion?
Br,
Eric
PS: I experienced also some rounding error with the convert function: convert (LogAttr1 / LongAttr2 *100) is giving 99.0 as result if LongAttr1 = 2 and LongAttr2 = 2