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

Add Support for MIN, MAX Aggregate Functions when run with custom window frames #4402

Closed
mustafasrepo opened this issue Nov 28, 2022 · 0 comments · Fixed by #4675
Closed
Labels
enhancement New feature or request

Comments

@mustafasrepo
Copy link
Contributor

Is your feature request related to a problem or challenge? Please describe what you are trying to do.

Currently, there is no support for queries involving MIN, MAX Aggregate functions when run with

custom window frames (queries involving window frame boundaries) such as below.

SELECT
MIN(c12) OVER (ORDER BY C12 RANGE BETWEEN 0.2 PRECEDING AND 0.2 FOLLOWING) as min1,
MAX(c12) OVER (ORDER BY C12 RANGE BETWEEN 0.2 PRECEDING AND 0.2 FOLLOWING) as max1
FROM aggregate_test_100
ORDER BY C9
LIMIT 5

I want support for this functionality

Describe the solution you'd like

Each accumulator has a retract_batch method, this method is used, when the window expression contains bounded window frame boundaries. By implementing retract_batch method of MIN, MAX accumulators. We can support this functionality (as in the SUM, COUNT accumulators)

Describe alternatives you've considered

N.A

Additional context

There is an amortized constant method to calculate min, max values using heap structure described in the link.

There is a crate implementing above algorithm.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant