Stream Name Issue

View: New views
2 Messages — Rating Filter:   Alert me  

Stream Name Issue

by sdicocco :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hello

I am using version 3.2.0 of Esper and have found what appears to be a bug in the way that the EPL is being compiled.

I am using a very simple POJO as a test object with the following fields all with respective getter and setters.

public class SimpleEvent
{
        private String uuid;
        private Integer sourceId;
        private Integer protocolId;
}

The following statement fails to register because it cannot find "A0.sourceId"

select * from Event as A0 where A0.sourceId = 3

The problem appears to be in the optimization that is done in StatementLifecycleSvcImpl.compile(...) at line 784.

the comment is as follows
// If not using a join and not specifying a data window, make the where-clause, if present, the filter of the stream

What it is doing is if there are no joins and no windows defined it assumes that it can move the where clause up and use it as a filter.  It does this naively here

810:    FilterStreamSpecRaw streamSpec = (FilterStreamSpecRaw) spec.getStreamSpecs().get(0);
811:    streamSpec.getRawFilterSpec().getFilterExpressions().add(whereClause);

the problem is that by simple copying that up you end up with the following query.

select * from Event( A0.sourceId = 3 ) as A0

this optimization makes the statement invalid because it is trying to reference that A0 before it is defined.

In order to be able to make that level of optimization it would have to check whether or not any of the properties in the where clause is referenced by an alias and then if it is either remove the reference to the alias or not make the optimization in that case.  However otherwise this prevents what should be a valid statement from being able to compile.

I have included a simple test case that will show the problem.  it attempts to register 3 queries.  Two valid queries that are similar and the above query.

"select * from Event where sourceId = protocolId"         //passes - because there is no stream name
"select * from Event as E_A1 where E_A1.sourceId = E_A1.protocolId"         //FAILS
"select * from Event.win:length(4) as E_A1 where E_A1.protocolId = E_A1.sourceId"         //passes - because there is a window defined

EsperBehaviorTest.tar

Re: Stream Name Issue

by Thomas Bernhardt :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Some parts of this message have been removed. Learn more about Nabble's security policy.
Hi.
I have created http://jira.codehaus.org/browse/ESPER-418 to track this issue.

Best regards
Tom

From: sdicocco <sdicocco@...>
To: user@...
Sent: Wed, October 28, 2009 2:39:26 PM
Subject: [esper-user] Stream Name Issue


Hello

I am using version 3.2.0 of Esper and have found what appears to be a bug in
the way that the EPL is being compiled.

I am using a very simple POJO as a test object with the following fields all
with respective getter and setters.

public class SimpleEvent
{
    private String uuid;
    private Integer sourceId;
    private Integer protocolId;
}

The following statement fails to register because it cannot find
"A0.sourceId"

select * from Event as A0 where A0.sourceId = 3

The problem appears to be in the optimization that is done in
StatementLifecycleSvcImpl.compile(...) at line 784.

the comment is as follows
// If not using a join and not specifying a data window, make the
where-clause, if present, the filter of the stream

What it is doing is if there are no joins and no windows defined it assumes
that it can move the where clause up and use it as a filter.  It does this
naively here

810:    FilterStreamSpecRaw streamSpec = (FilterStreamSpecRaw)
spec.getStreamSpecs().get(0);
811: 
streamSpec.getRawFilterSpec().getFilterExpressions().add(whereClause);

the problem is that by simple copying that up you end up with the following
query.

select * from Event( A0.sourceId = 3 ) as A0

this optimization makes the statement invalid because it is trying to
reference that A0 before it is defined.

In order to be able to make that level of optimization it would have to
check whether or not any of the properties in the where clause is referenced
by an alias and then if it is either remove the reference to the alias or
not make the optimization in that case.  However otherwise this prevents
what should be a valid statement from being able to compile.

I have included a simple test case that will show the problem.  it attempts
to register 3 queries.  Two valid queries that are similar and the above
query.

"select * from Event where sourceId = protocolId"        //passes - because
there is no stream name
"select * from Event as E_A1 where E_A1.sourceId = E_A1.protocolId"       
//FAILS
"select * from Event.win:length(4) as E_A1 where E_A1.protocolId =
E_A1.sourceId"        //passes - because there is a window defined

http://www.nabble.com/file/p26099881/EsperBehaviorTest.tar
EsperBehaviorTest.tar
--
View this message in context: http://www.nabble.com/Stream-Name-Issue-tp26099881p26099881.html
Sent from the Esper User list mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email