esper icon indicating copy to clipboard operation
esper copied to clipboard

prepared statement alters pattern definition

Open andyflury opened this issue 11 years ago • 2 comments

I have the following prepared statement:

select * from pattern [every a=A -> (timer:at(?, *, *, *, 1:5) and not A)]

Once it is deployed its definition is changed to the following

select * from pattern [every a=A -> timer:at(?, *, *, *, 1:5) and not A]

Since the brackets have been removed it now has a different semantic.

see test class below:

public static void main(String[] args) throws InterruptedException {

    Configuration config = new Configuration();
    config.addEventType(A.class);

    EPServiceProvider epService = EPServiceProviderManager.getDefaultProvider(config);

    String epl = "select * from pattern [every a=A -> (timer:at(?, *, *, *, 1:5) and not A)]";

    EPPreparedStatement prepared = epService.getEPAdministrator().prepareEPL(epl);
    prepared.setObject(1, 0);

    EPStatementImpl statement = (EPStatementImpl) epService.getEPAdministrator().create(prepared);
    String newEpl = statement.getStatementContext().getEpStatementHandle().getEPL();
    System.out.println(newEpl);

    epService.getEPRuntime().sendEvent(new A());

    epService.destroy();
}

public static class A {
}

andyflury avatar Jun 16 '15 15:06 andyflury

"->" has the lowest precedence so it is the same with or without paren.

bernhardttom avatar Jun 16 '15 16:06 bernhardttom

I see, thanks

andyflury avatar Jun 16 '15 16:06 andyflury