Skip to content
Advertisement

Access user defined method properties on query – Esper

I implemented a query where i mined data from a database but i have to change it so i mine my data from a custom function in my code. I read the documentation and added the annotation import on the configuration. The query throws that error:

Failed to resolve event type, named window or table by name 'path.to.my.class.customfunction'

I don’t know the type that my function have to return but i tried Arraylist and Hashmaps with key an integer and value a custom class and didn’t work.

My final query want to look like this :

select * from LocationEvent as loc,
                   ***CustomFuntion()*** as product
                        where loc.id=product.id  ;

I kept the structure i used for database connection. I don’t know if there is another way to solve this. Thanks.

EDIT: I managed to make call the custom function with that query :

select  path.to.class.getProducts() as product from pattern[every timer:interval(3 sec)]

My function right now return an ArrayList and the query returns this:

[Product{ProductID=124,.....,},Product{...}]

So now my problem is that i can’t access properties of Product on the query like products.ProductID

Advertisement

Answer

If you want to have a custom function in the from-clause you can use the “method:”. The docs have this described here: Accessing Non-Relational Data via Method. The Esper runtime then calls your method to get events/rows.

User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement