Closed tammypi closed 5 years ago
I have already found the code which occur the error. GroupConcatFunctionExtension.java
The code: ` @Override public Object processAdd(Object o) { addString((String) o); return constructConcatString(","); }
@Override
public Object processAdd(Object[] objects) {
addString((String) objects[0]);
return constructConcatString((String) objects[1]);
}
@Override
public Object processRemove(Object o) {
removeString((String) o);
return constructConcatString(",");
}
@Override
public Object processRemove(Object[] objects) {
removeString((String) objects[0]);
return constructConcatString((String) objects[1]);
}`
should be changed as below:
`@Override public Object processAdd(Object o) { addString(String.valueOf(o)); return constructConcatString(","); }
@Override
public Object processAdd(Object[] objects) {
addString(String.valueOf(objects[0]));
return constructConcatString(String.valueOf(objects[1]));
}
@Override
public Object processRemove(Object o) {
removeString(String.valueOf(o));
return constructConcatString(",");
}
@Override
public Object processRemove(Object[] objects) {
removeString(String.valueOf(objects[0]));
return constructConcatString(String.valueOf(objects[1]));
}`
Description: The first parameter type in function groupConcat is String. So if the column I need to use in function groupConcat is not string, I need to cast the column type to string. But there still throw an exception "Integer cannot cast to string" even I have already cast the column type to string.
Affected Product Version:
4.0.24
Steps to reproduce:
-- Please refer to https://docs.wso2.com/display/SP400/Quick+Start+Guide on getting started with SP editor.
define stream inputstream (id string,weight int);
@sink(type='log', prefix='LOGGER') define stream OutputStream(id string,weight string);
@info(name='GroupbyQuery') from inputstream#window.timeBatch(10 second) select id,str:groupConcat(cast(weight,'string'),',',true) as weight group by id insert into OutputStream;`
[2018-12-28_08-58-27_187] ERROR {org.wso2.siddhi.core.query.processor.stream.AbstractStreamProcessor} - Error on 'GroupByApp'. java.lang.Integer cannot be cast to java.lang.String Dropping event chunk EventChunk{first=StreamEvent{ timestamp=1545958697185, beforeWindowData=null, onAfterWindowData=[1], outputData=[1, null], type=CURRENT, next=null}}, error in processing org.wso2.siddhi.core.query.processor.stream.window.TimeBatchWindowProcessor. (Encoded) java.lang.ClassCastException: java.lang.Integer cannot be cast to java.lang.String at org.wso2.extension.siddhi.execution.string.GroupConcatFunctionExtension.processAdd(GroupConcatFunctionExtension.java:167) at org.wso2.siddhi.core.query.selector.attribute.aggregator.AttributeAggregator.process(AttributeAggregator.java:82) at org.wso2.siddhi.core.query.selector.attribute.processor.executor.GroupByAggregationAttributeExecutor.execute(GroupByAggregationAttributeExecutor.java:92) at org.wso2.siddhi.core.query.selector.attribute.processor.AttributeProcessor.process(AttributeProcessor.java:41) at org.wso2.siddhi.core.query.selector.QuerySelector.processInBatchGroupBy(QuerySelector.java:293) at org.wso2.siddhi.core.query.selector.QuerySelector.process(QuerySelector.java:84) at org.wso2.siddhi.core.query.processor.stream.window.TimeBatchWindowProcessor.process(TimeBatchWindowProcessor.java:254) 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:125) at org.wso2.siddhi.core.query.input.stream.single.EntryValveProcessor.process(EntryValveProcessor.java:50) at org.wso2.siddhi.core.util.Scheduler.sendTimerEvents(Scheduler.java:197) at org.wso2.siddhi.core.util.Scheduler$EventCaller.run(Scheduler.java:249) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180) at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) at java.lang.Thread.run(Thread.java:745)