1

I have a UDF in Esper which returns an int

getVal(int val){
//doing stuff
return val;
}

if i do this

select getVal(eventAttribute) from Event

it returns

{getVal(eventAttribute)=3 } //3 example could be anything

However if i specify

select getVal(eventAttribute) from Event WHERE getVal(eventAttribute) = 3

the listener wont update

Does anyone know why? Do I have to set the attribute in the Event class? since it updates from the select clause but with a WHERE clause even though it returns an int = 3

EDIT:

insert into Stream select getVal(attribute) as value

select value from Stream where value > 3

This works.

wandapong
  • 59
  • 5

1 Answers1

0

Are you sure that "getVal" always returns the same value for a given "eventAttribute" and "eventAttribute" is immutable? If yes provide some test code to reproduce?

user3613754
  • 816
  • 1
  • 5
  • 5
  • when i execute two methods in the same query with the same attribute, they have to be the same? If i use ID and during execution the ID = 1 in the method parameter it will be 1 on both invocations in the EPL no? – wandapong Jan 26 '17 at 00:02
  • 1
    Esper doesn't remember that "getVal" returned a given value. That's also because Esper may not even execute the select clause or may execute it much later than the filter. The "getVal" function itself can remember what it returned, if it wants to, as long as the function is thread-safe. Or one could treat it more like an enrichment and use insert into, like this "insert into NewStream select *, getVal(attribute) as computedValue from Event" and then use "NewStream" and "computedValue" instead of "Event" and "getVal(...)" – user3613754 Jan 26 '17 at 00:13