0

I am trying to create a siddhi application where it adds output when a person is in proximity to certain preset locations. These locations are stored in the database. The input is sent from postman as of now.

But I keep getting the error saying the datatype is not 'double'. I have even checked the table details and the datatype in mysql table is set to double.

Following are the details for siddhi code and the error. Can someone please guide me.

location for the siddhi extension: https://wso2-extensions.github.io/siddhi-gpl-execution-geo/api/latest/

Siddhi code:

@App:name('ShipmentHistoryApp')

@source(type = 'http', receiver.url='http://localhost:5008/RawMaterials', @map(type = 'json'))
define stream WalkingStream(latitude DOUBLE, longitude DOUBLE, device_id string);

@store(type='rdbms', jdbc.url="jdbc:mysql://127.0.0.1:3306/SweetFactoryDB", username="root", password="root" , jdbc.driver.name="com.mysql.jdbc.Driver")
define table Offers(c string, offer string, latitude DOUBLE, longitude DOUBLE);

@sink(type='log')
define stream SetLocation(a string, b string,one bool, two bool, dis double);

@sink(type='log', prefix='Only log')
define stream info(one bool, two bool);

from WalkingStream as w
join SetLocation as o
select o.a, o.b, instanceOfDouble(o.latitude) as one, instanceOfDouble(o.longitude) as two, geo:distance(w.latitude,w.longitude,o.latitude,o.longitude) as dis insert into Output;  

I'm getting this error when trying to find distance between two locations.

org.wso2.siddhi.core.exception.SiddhiAppRuntimeException: Invalid input given to geo:distance() function. Third argument should be double
    at org.wso2.extension.siddhi.gpl.execution.geo.function.GeoDistanceFunctionExecutor.execute(GeoDistanceFunctionExecutor.java:123)
    at org.wso2.siddhi.core.executor.function.FunctionExecutor.execute(FunctionExecutor.java:109)
    at org.wso2.siddhi.core.query.selector.attribute.processor.AttributeProcessor.process(AttributeProcessor.java:41)
    at org.wso2.siddhi.core.query.selector.QuerySelector.processNoGroupBy(QuerySelector.java:145)
    at org.wso2.siddhi.core.query.selector.QuerySelector.process(QuerySelector.java:87)
    at org.wso2.siddhi.core.query.input.stream.join.JoinProcessor.process(JoinProcessor.java:110)
    at org.wso2.siddhi.core.query.processor.stream.window.LengthWindowProcessor.process(LengthWindowProcessor.java:135)
    at org.wso2.siddhi.core.query.processor.stream.window.WindowProcessor.processEventChunk(WindowProcessor.java:66)
    at org.wso2.siddhi.core.query.processor.stream.AbstractStreamProcessor.process(AbstractStreamProcessor.java:123)
    at org.wso2.siddhi.core.query.input.stream.join.JoinProcessor.process(JoinProcessor.java:118)
    at org.wso2.siddhi.core.query.input.ProcessStreamReceiver.processAndClear(ProcessStreamReceiver.java:187)
    at org.wso2.siddhi.core.query.input.ProcessStreamReceiver.process(ProcessStreamReceiver.java:97)
    at org.wso2.siddhi.core.query.input.ProcessStreamReceiver.receive(ProcessStreamReceiver.java:133)
    at org.wso2.siddhi.core.stream.StreamJunction.sendEvent(StreamJunction.java:151)
    at org.wso2.siddhi.core.stream.StreamJunction$Publisher.send(StreamJunction.java:358)
    at org.wso2.siddhi.core.stream.input.InputDistributor.send(InputDistributor.java:34)
    at org.wso2.siddhi.core.stream.input.InputEntryValve.send(InputEntryValve.java:44)
    at org.wso2.siddhi.core.stream.input.InputHandler.send(InputHandler.java:61)
    at org.wso2.siddhi.core.stream.input.source.PassThroughSourceHandler.sendEvent(PassThroughSourceHandler.java:35)
    at org.wso2.siddhi.core.stream.input.source.InputEventHandler.sendEvent(InputEventHandler.java:76)
    at org.wso2.extension.siddhi.map.json.sourcemapper.JsonSourceMapper.mapAndProcess(JsonSourceMapper.java:211)
    at org.wso2.siddhi.core.stream.input.source.SourceMapper.onEvent(SourceMapper.java:132)
    at org.wso2.extension.siddhi.io.http.source.HttpWorkerThread.run(HttpWorkerThread.java:62)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
    at java.lang.Thread.run(Thread.java:748)

Alternatively I've also tried to cast the latitude from table into double in the query.

  • My findings led me to https://stackoverflow.com/questions/39484771/handling-null-values-with-wso2-cep . Has this been solved in wso2 stream processor 4.0? Or is there a work around. – dhruv shah Mar 03 '18 at 17:51

1 Answers1

0

This can be occurred when the 3rd argument of geo:distance function becomes null. Can you verify whether o.latitude can become null?

Minudika
  • 851
  • 6
  • 23
  • Hey, I've checked the null(ness) of o.latitude with : `[not (latitude is null or longitude is null)]` and also a custom javascript function i wrote with `if` conditions. – dhruv shah Mar 03 '18 at 17:47