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 OVER(PARTITION BY ...) clause #3698

Open
enwi opened this issue Mar 6, 2024 · 2 comments
Open

Add OVER(PARTITION BY ...) clause #3698

enwi opened this issue Mar 6, 2024 · 2 comments

Comments

@enwi
Copy link

enwi commented Mar 6, 2024

Why the new feature should be added

Currently for example SQLExpressions.percentileCont(...) only supports .withinGroup().orderBy(...), but not .over().partitionBy(..)

How the new feature should work

It would be awesome to be able to write SQLExpressions.percentileCont(0.25).withinGroup().orderBy("value").over().partitionBy("series") to get PERCENTILE_CONT(0.25) WITHIN GROUP (ORDER BY value) OVER (PARTITION BY series)

@dodgex
Copy link
Contributor

dodgex commented Apr 12, 2024

As there is already support for this with SQLExpressions.count() (e.g. SQLExpressions.count().over().partitionBy((Expression<?>) null)) you could try to do something like this to achieve your percentile count with OVER ()

       new WindowFunction<>(SQLExpressions.percentileCont((Expression<Number>) null))
                .partitionBy((Expression<?>) null);

The nulls of course have to be replaced with your proper Expressions. :)

As an exlanation: SQLExpressions.count() returns a WindowOver instance providing the .over() which then returns a WindowFunction that brings the partitionBy() method.

This is not tested and only assumed to work. But the code gives me good hope, that it should.

@enwi
Copy link
Author

enwi commented Apr 18, 2024

Thanks for the reply @dodgex . I will give it a try and report back :)

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