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

rollup for freq_agg and topn_agg #685

Closed
gugu opened this issue Jan 17, 2023 · 0 comments · Fixed by #696
Closed

rollup for freq_agg and topn_agg #685

gugu opened this issue Jan 17, 2023 · 0 comments · Fixed by #696
Assignees
Labels
feature-request And area of analysis that could be made easier

Comments

@gugu
Copy link

gugu commented Jan 17, 2023

Is your feature request related to a problem? Please describe.
I have several dailytopn_agg() values in materialized view and I want to aggregate them to get topn_agg() values for a week, for example

Describe the solution you'd like
Add rollup function for topn_agg() and freq_agg() the same way as it works for other aggregates

CREATE MATERIALIZED VIEW hourly AS
    SELECT timebucket('1hour', dt) as hour, TOPN_AGG(100, field) as field_topn FROM raw_table GROUP BY 1;
SELECT topn(10, rollup(field_topn)) FROM hourly WHERE hour BETWEEN 'A' and 'B'

Describe alternatives you've considered
It it possible to get all the topn_agg() results to the app and aggregate in business logic, but it requires downloading of 6MB hourly data to get a monthly value

Additional context
There is already space_saving_aggregate_combine rust function, which does exactly what I need, but it is not exposed

@gugu gugu added the feature-request And area of analysis that could be made easier label Jan 17, 2023
@WireBaron WireBaron self-assigned this Jan 18, 2023
bors bot added a commit that referenced this issue Feb 6, 2023
696: Add rollup functionality to frequency aggregates r=WireBaron a=WireBaron

This change implements adds in rollup functions for frequency aggregates.

Note that while the rollup of a set of frequency aggregates will not necessarily be identical to computing a single aggregate over the underlying data (may not have the exact same upper and lower bounds on frequency), the rollup maintains the same invariants and will be able to identify most common elements as long as the frequency is different enough.

Fixes #685 

Co-authored-by: Brian Rowe <brian@timescale.com>
@bors bors bot closed this as completed in cac9a9e Feb 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature-request And area of analysis that could be made easier
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants