Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#unique not summing up correctly based on order of events #269

Closed
dakotahNorth opened this issue Nov 2, 2022 · 1 comment
Closed

#unique not summing up correctly based on order of events #269

dakotahNorth opened this issue Nov 2, 2022 · 1 comment

Comments

@dakotahNorth
Copy link

@unique is working differently depending on the sequence of events.

Given the following epl:

create schema StockTick(security string, price double);
create schema OrderEvent (orderId int, trader string, symbol string, strategy string, 
quantity double);

select orderId, trader, symbol, strategy, sum(quantity) 
from OrderEvent#unique(orderId) as o
full outer join StockTick#lastevent as t 
on o.symbol = t.security
group by trader, symbol, strategy

The following events:

StockTick={security='IBM', price=99}
OrderEvent={orderID=1, trader="A", symbol='IBM', strategy="VWAP", quantity=10}
StockTick={security='IBM', price=99}

correctly provides the sum as sum(quantity)=10.0.

But if the StockTick did not happen first:

OrderEvent={orderID=1, trader="A", symbol='IBM', strategy="VWAP", quantity=10}
StockTick={security='IBM', price=99}

I still expected the value of quantity to be 10. But in this case it is sum(quantity)=20.0!!

Why is #unique(field) not being adhered to and what is needed in the query for the output to be unique on orderId for both cases?

The following set of events is also available to run on Esper Notebook
https://notebook.esperonline.net/#/notebook/2HE9662E6

@bernhardttom
Copy link
Contributor

Checked the docs on aggregations with joins? Is not the same as relational

@bernhardttom bernhardttom closed this as not planned Won't fix, can't repro, duplicate, stale Nov 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants