-
Notifications
You must be signed in to change notification settings - Fork 1.9k
This issue was moved to a discussion.
You can continue the conversation there. Go to discussion →
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
Add exp-weighted functions to DuckDB #5139
Comments
The pandas documentation is here. This is a right royal pain to do in straight SQL - you have to compute the weights using To implement this as a window function using segment trees, you would need the I think this will have to wait until we get a chance to refactor the segment trees to be on a function-by-function basis, with a common default for most. This would also facilitate the new merge sort trees approach that Adrian presented at SIGMOD 2022. |
Thanks for taking a look at it Richard! I'm not sure I follow how the double My naive idea was to have a dedicated aggregate function that carries state across rows. |
This issue is stale because it has been open 90 days with no activity. Remove stale label or comment or this will be closed in 30 days. |
Unless you guys feel there is a good reason to close this, I'd keep it open. There is currently still no way to do this efficiently in duckdb, UDAF might be an option when it comes available and assuming performance is good there. Just to provide a bit more justification to keep this open, the same functionalities exists / has been requested in polars, spark, cudf, dask |
This issue is stale because it has been open 90 days with no activity. Remove stale label or comment or this will be closed in 30 days. |
I can't remove the tag myself so I guess I'll comment |
Definitely waiting for this feature..! |
This issue is stale because it has been open 90 days with no activity. Remove stale label or comment or this will be closed in 30 days. |
Bump |
This is a feature, not a bug, so please convert this to a discussion if you want it kept alive. Thx. |
I filed this one, how do I convert it to a discussion? |
I'm not sure! I did find this document but maybe you need to do it? |
I can't seem to find the button either (it's not on the right side like the doc suggests, probably I don't have the right privs), is it ok if I keep this one open for now or anybody with the right privilege can move it to discussion if needed? |
This issue was moved to a discussion.
You can continue the conversation there. Go to discussion →
Exponentially weighted functions are used frequently in the finance world but they are tricky to implement in SQL.
In the pandas they are
ewm().<<function>>
(sum, mean, stdev, var) and they are implemented in cythonThe logic to implement them is not too complicated but it requires carrying state across rows.
A user could implement them using
with recursive
but that's slow or using a UDAF but that isn't a thing in DuckDB AFAIK.I asked on Discord if people felt they would be useful to have them in DuckDB and Alex seemed supportive (not sure why tagging him doesn't work), filing this issue as per @hawkfish suggestion.
Is that something you feel should go into DuckDB core (asking here as per Contributing Guidelines)? My biased sense is yes, not many others are offering these functionalities and it seems kind of low-hanging fruit.
Do you feel this is within the level of complexity an outsider can implement? I'll for sure need some help, I only contributed #4259
If yes, I'd volunteer to do the work to add
sum_w
andmean_w
(name tbd), starting with exposing onlyalpha
parameter.Most other parameters are just ways to implement the same thing,
adjust
should probably be True most of the times anyway andignore_na
is something a user can deal with using filter conditions.Also
std
andvar
could be in another PR.PS: I didn't use the standard template as this is not a bug, happy to switch
The text was updated successfully, but these errors were encountered: