Handling null values with wso2 CEP

2019-07-16 07:56发布

问题:

I want to update event table (RDBMS) using additional condition that one column in that is not null. Table name is MSISDNProfileDB and it's in oracle db.

from incomingStream#window.length(1)
select  correlation_MSISDN as MSISDN, 
        INTERACTION_DT as INTERACTION_DT
update MSISDNProfileDB
on MSISDNProfileDB.MSISDN == MSISDN
and not(MSISDNProfileDB.column1 is null);

it validates the code, but does not update INTERACTION_DT. For testing purposes, I changed it to check if the column is null, and manually remove data from column1.

from incomingStream#window.length(1)
select  correlation_MSISDN as MSISDN, 
        INTERACTION_DT as INTERACTION_DT
update MSISDNProfileDB
on MSISDNProfileDB.MSISDN == MSISDN
and MSISDNProfileDB.column1 is null;

...and it still doesnt work. But when I change column value to 1 and do this:

from incomingStream#window.length(1)
select  correlation_MSISDN as MSISDN, 
        INTERACTION_DT as INTERACTION_DT
update MSISDNProfileDB
on MSISDNProfileDB.MSISDN == MSISDN
and MSISDNProfileDB.column1 == '1';

it works! So, conclusion is that cep has problem with null values from oracle db. Does anyone knows how are null values handled?

Kind Regards, Stefan

回答1:

I came across a similar problem with MySQL. The issue seems to be in the way CEP parse Siddhi query into SQL. I did a quick fix for that, and it worked for my scenario. It should work in your case too, but haven't tested with Oracle though. To use the fix (assuming you are using CEP 4.2.0);

  1. Delete siddhi-extension-event-table_3.1.2.jar from <cep>/repository/components/plugins/ directory.

  2. Add compiled jar to <cep>/repository/components/lib/ diectory.

  3. Use following query;

    from incomingStream
    select  
        correlation_MSISDN as MSISDN, 
        INTERACTION_DT as INTERACTION_DT
    update MSISDNProfileDB
    on MSISDNProfileDB.MSISDN == MSISDN and not (MSISDNProfileDB.column1 is null);