Search code examples
timestampespercomplex-event-processing

Esper: Using start/end-timestamps with POJOs or runtime defined event types


I am trying to use the time interval algebra methods on event types directly, which, according to the docs, should be possible. I first tried to define some event types using the create schema syntax, like this:

create schema BaseEvent as (time long, name String) starttimestamp time
create schema ExtendedEvent as (moreInfo String) inherits BaseEvent

If I write a query like this

select *
    from BaseEvent.std:lastevent() as a, ExtendedEvent.std:lastevent() as b
    where a.after(b)

it actually compiles without error. But if I try to use a pattern instead of a join, like this

select *
    from pattern [ every (a = BaseEvent and b = ExtendedEvent) ]
    where a.after(b)

it gives me an error:

Date-time enumeration method 'after' requires either a Calendar,
Date or long value as input or events of an event type that
declares a timestamp property

I get the same error when I try to use POJOs that are derived from a base event type which has the timestamp properties defined as described in the documentation. While it works when I actually use the base type, it seems strange that Esper does not use the inherited time property in this case, when it does use information about inheritance it in every other case.

Am I doing something wrong? Is this a bug? Or maybe it just works as intended...


Solution

  • It actually was kind of a bug or a 'missing' feature:

    There are actually two issues I got confused here. The first is that inheritance in Esper does not work that way, i.e. derived types do not automatically inherit timestamp properties. The other problem is, that the events resulting from a pattern are so called fragments, which are not supported by the date-time methods.

    The good thing is, with the upcoming version of Esper, 4.6.0, both 'issues' will be fixed: ESPER-659 and ESPER-660.