0

I am using the WSO2 CEP and I have create the following Execution plan:

  define stream sensor1Stream (timestamp string, id string, latitude double, longitude double, altitude double);

  define stream sensor2Stream (timestamp string, id string, latitude double, longitude double, altitude double);

  define stream alertStream (alert_id bool, alert_level string, accuracy_level string, s1_timestamp string, s1_id string, s1_latitude double, s1_longitude double, s1_altitude double, s2_timestamp string, s2_id string, s2_latitude double, s2_longitude double, s2_altitude double);

    from sensor1Stream
    select timestamp as s1_timestamp, id as s1_id, latitude as s1_latitude, longitude as s1_longitude, altitude as s1_altitude
    insert into alertStream(s1_timestamp, s1_id, s1_latitude, s1_longitude, s1_altitude);

    from sensor2Stream
    select timestamp as s2_timestamp, id as s2_id, latitude as s2_latitude, longitude as s2_longitude, altitude as s2_altitude
    insert into alertStream(s2_timestamp, s2_id, s2_latitude, s2_longitude, s2_altitude);

I want to insert the attributes from sensor1Stream and sensor2Stream in the alertStream. I have tried the above way, but does not work because of an error:

"You have an error in your SiddhiQL at line 39:23, extraneous input '(' expecting {, ';'}"

The error is between the alertStream and the parenthesis in the last line of the Execution Plan.

I do not know what I am doing wrong. I would be very grateful if somebody could help me on this matter.

Thanks!

Community
  • 1
  • 1
fay
  • 49
  • 1
  • 7

1 Answers1

0

Please find an example of a Siddhi execution plan below:

@Plan:name('ExecutionPlan')

@Import('org.wso2.event.sensor.stream:1.0.0')
define stream sensor_stream (meta_timestamp long, meta_isPowerSaverEnabled bool, meta_sensorId int, meta_sensorName string, correlation_longitude double, correlation_latitude double, humidity float, sensorValue double);

@Export('org.wso2.sensor.value.projected.stream:1.0.0')
define stream sensor_value_projected_stream (meta_sensorId int, correlation_longitude double, correlation_latitude double, humidity float, value double);

from sensor_stream
select meta_sensorId, correlation_longitude, correlation_latitude, humidity, sensorValue as value
insert into sensor_value_projected_stream;

This example is taken from Siddhi sample 'Pass-Through/Projection Query in an Execution Plan'.

You can refer more Siddhi samples here on WSO2 CEP documentation page. This Siddhi QL guide provides complete reference on Siddhi language.

Dilini
  • 777
  • 8
  • 22
  • Hi! Thank you very much for your response! I based on your example and I removed the attributes in the parenthesis from "insert into alertStream". But now a new error is occurring. I have post the error in the next two comments. Could you please help me to solve it? Thanks! – fay May 31 '17 at 08:32
  • "Different definition same as output stream definition :StreamDefinition{id='alertStream', attributeList=[Attribute{id='s1_timestamp', type=STRING}, Attribute{id='s1_id', type=STRING}, Attribute{id='s1_latitude', type=DOUBLE}, Attribute{id='s1_longitude', type=DOUBLE}, Attribute{id='s1_altitude', type=DOUBLE}], annotations=[]} already exist as:StreamDefinition{id='alertStream', attributeList=[Attribute{id='alert_id', type=BOOL}, Attribute{id='alert_level', type=STRING}, Attribute{id='accuracy_level', type=STRING}, Attribute{id='s1_timestamp', type=STRING}, Attribute{id='s1_id', type=STRING}, – fay May 31 '17 at 08:34
  • Attribute{id='s1_latitude', type=DOUBLE}, Attribute{id='s1_longitude', type=DOUBLE}, Attribute{id='s1_altitude', type=DOUBLE}, Attribute{id='s2_timestamp', type=STRING}, Attribute{id='s2_id', type=STRING}, Attribute{id='s2_latitude', type=DOUBLE}, Attribute{id='s2_longitude', type=DOUBLE}, Attribute{id='s2_altitude', type=DOUBLE}], annotations=[]} in execution plan" – fay May 31 '17 at 08:34
  • Hi, This is because the `select` statement must contain values for all the attributes of alertStream. Since the alertStream has 13 attributes, `select` statement has to have 13 values; currently you have only 5 values. – Dilini May 31 '17 at 08:40