siddhi-io / siddhi

Stream Processing and Complex Event Processing Engine
http://siddhi.io
Apache License 2.0
1.53k stars 528 forks source link

ClassCastException on casting string to integer value #1669

Open xtrmstep opened 4 years ago

xtrmstep commented 4 years ago

Hi,

I'm using 5.1.2 version of docker Siddhi runner.

I've got a code which looks very simple

from _temp_stream as e left outer join tbl_table as t
    on e.id==t.id
select ...,
cast('1', 'int') as field,
...
update or insert into tbl_table
    set 
        ...
    on tbl_table .id==id;

tbl_table is RDBMS store in Siddhi app and maps to table in PostgreSQL. The field has integer type in DB. In Siddhi this field has type int.

This code throws an error:

[2020-07-27_10-51-38_058] ERROR {io.siddhi.core.stream.StreamJunction} - Error in 'table' after consuming events from Stream '_temp_stream', null. Hence, dropping event '... some events information, field has integer values....' (Encoded) 
java.lang.ClassCastException

is it possible to trace the error more deeply to get more information what's wrong?

xtrmstep commented 4 years ago

test application

@App:name('test')
@App:statistics(enable='true', include='*.*') 

-- SOURCES
define stream inp_stream (
    id int,
    value string
);

-- TABLES

@store(type = 'rdbms',
    jdbc.url = "${POSTGRE_HOST}${POSTGRE_DB}",
    username = "${POSTGRE_USER}",
    password = "${POSTGRE_PASS}",
    jdbc.driver.name = "org.postgresql.Driver",
    table.name = "_tbl")
define table tbl_table (
    id int,
    value int
);

-- PROCESSING

@info(name='_tmp')
from inp_stream
select
    id,
    cast(default(value,'-1'), 'int') as value
insert into _tmp;

@info(name='tbl_table')
from _tmp as e left outer join tbl_table as t
    on e.id==t.id
select
    e.id,
    e.value
update or insert into tbl_table
    set 
        tbl_table.value=value
    on tbl_table.id==id;
xtrmstep commented 4 years ago

When I send 1 as a value for value in Siddhi tooling, I'm getting this error:

[2020-07-27_11-42-43_340] ERROR {io.siddhi.core.stream.StreamJunction} - Error in 'test' after consuming events from Stream '_tmp', java.lang.String cannot be cast to java.lang.Integer. Hence, dropping event 'StreamEvent{ timestamp=1595850163337, beforeWindowData=null, onAfterWindowData=[1], outputData=[1, 1], type=CURRENT, next=null}' (Encoded) java.lang.ClassCastException: java.lang.String cannot be cast to java.lang.Integer at io.siddhi.extension.store.rdbms.util.RDBMSTableUtils.populateStatementWithSingleElement(RDBMSTableUtils.java:306) at io.siddhi.extension.store.rdbms.util.RDBMSTableUtils.resolveCondition(RDBMSTableUtils.java:184) at io.siddhi.extension.store.rdbms.util.RDBMSTableUtils.resolveQuery(RDBMSTableUtils.java:195) at io.siddhi.extension.store.rdbms.RDBMSEventTable.query(RDBMSEventTable.java:1728) at io.siddhi.core.table.record.AbstractQueryableRecordTable.query(AbstractQueryableRecordTable.java:674) at io.siddhi.core.query.processor.stream.window.TableWindowProcessor.query(TableWindowProcessor.java:103) at io.siddhi.core.query.input.stream.join.JoinProcessor.query(JoinProcessor.java:196) at io.siddhi.core.query.input.stream.join.JoinProcessor.execute(JoinProcessor.java:135) at io.siddhi.core.query.input.stream.join.JoinProcessor.process(JoinProcessor.java:97) at io.siddhi.core.query.processor.stream.window.EmptyWindowProcessor.process(EmptyWindowProcessor.java:93) at io.siddhi.core.query.processor.stream.window.EmptyWindowProcessor.process(EmptyWindowProcessor.java:50) at io.siddhi.core.query.processor.stream.window.BatchingWindowProcessor.processEventChunk(BatchingWindowProcessor.java:74) at io.siddhi.core.query.processor.stream.AbstractStreamProcessor.process(AbstractStreamProcessor.java:132) at io.siddhi.core.query.input.stream.join.JoinProcessor.process(JoinProcessor.java:87) at io.siddhi.core.query.input.ProcessStreamReceiver.processAndClear(ProcessStreamReceiver.java:182) at io.siddhi.core.query.input.ProcessStreamReceiver.process(ProcessStreamReceiver.java:84) at io.siddhi.core.query.input.ProcessStreamReceiver.receive(ProcessStreamReceiver.java:115) at io.siddhi.core.stream.StreamJunction.sendEvent(StreamJunction.java:176) at io.siddhi.core.stream.StreamJunction$Publisher.send(StreamJunction.java:465) at io.siddhi.core.query.output.callback.InsertIntoStreamCallback.send(InsertIntoStreamCallback.java:56) at io.siddhi.core.query.output.ratelimit.OutputRateLimiter.sendToCallBacks(OutputRateLimiter.java:104) at io.siddhi.core.query.output.ratelimit.PassThroughOutputRateLimiter.process(PassThroughOutputRateLimiter.java:44) at io.siddhi.core.query.selector.QuerySelector.process(QuerySelector.java:97) at io.siddhi.core.query.input.ProcessStreamReceiver.processAndClear(ProcessStreamReceiver.java:182) at io.siddhi.core.query.input.ProcessStreamReceiver.process(ProcessStreamReceiver.java:84) at io.siddhi.core.query.input.ProcessStreamReceiver.receive(ProcessStreamReceiver.java:127) at io.siddhi.core.stream.StreamJunction.sendEvent(StreamJunction.java:199) at io.siddhi.core.stream.StreamJunction$Publisher.send(StreamJunction.java:474) at io.siddhi.core.stream.input.InputDistributor.send(InputDistributor.java:34) at io.siddhi.core.stream.input.InputEntryValve.send(InputEntryValve.java:45) at io.siddhi.core.stream.input.InputHandler.send(InputHandler.java:78) at io.siddhi.distribution.editor.core.internal.DebuggerEventStreamService.pushEvent(DebuggerEventStreamService.java:74) at io.siddhi.distribution.event.simulator.core.internal.generator.SingleEventGenerator.sendEvent(SingleEventGenerator.java:85) at io.siddhi.distribution.event.simulator.core.impl.SingleApiServiceImpl.runSingleSimulation(SingleApiServiceImpl.java:20) at io.siddhi.distribution.event.simulator.core.api.SingleApi.runSingleSimulation(SingleApi.java:72) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at org.wso2.msf4j.internal.router.HttpMethodInfo.invokeResource(HttpMethodInfo.java:187) at org.wso2.msf4j.internal.router.HttpMethodInfo.invoke(HttpMethodInfo.java:143) at org.wso2.msf4j.internal.MSF4JHttpConnectorListener.dispatchMethod(MSF4JHttpConnectorListener.java:218) at org.wso2.msf4j.internal.MSF4JHttpConnectorListener.lambda$onMessage$58(MSF4JHttpConnectorListener.java:129) at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) at java.lang.Thread.run(Unknown Source)

ngocdangrby commented 4 years ago

Using convert(attribute, new_type) instead of cast()

eg: cast(value, 'int') as value