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

Support For SQL Window Functions #408

Closed
simpleisbest opened this issue Apr 30, 2013 · 6 comments
Closed

Support For SQL Window Functions #408

simpleisbest opened this issue Apr 30, 2013 · 6 comments
Milestone

Comments

@simpleisbest
Copy link

@simpleisbest simpleisbest commented Apr 30, 2013

Please add support for ROW_NUMBER() OVER (PARTITION BY foo ORDER BY Date) using QueryDSL.

For example

SELECT *, ROW_NUMBER() OVER (
        PARTITION BY foo
        ORDER BY bar)
FROM foobar

Windows functions are ANSI standard now and work on most databases.

It would also be nice if QueryDSL supported additional window functions like rank() as well

Window Functions in SQL
http://en.wikipedia.org/wiki/Select_(SQL)

@timowest
Copy link
Member

@timowest timowest commented May 2, 2013

The starting methods could be put into SQLExpressions as sum, count, avg, min, max, lead, lag, rank, denseRank, rowNumber, first, firstValue, last and lastValue.

An example invocation could be

SQLExpressions.rowNumber().over().partitionBy(foo).orderBy(bar)
@lukaseder
Copy link

@lukaseder lukaseder commented May 2, 2013

Beautiful API design choice ;-)

@timowest
Copy link
Member

@timowest timowest commented May 2, 2013

Yes, it's similar to jOOQ, but there are not many reasonable alternatives. I considered also the reverse order

over().partitionBy(foo).orderBy(bar).rowNumber()

which would be more in line with the Querydsl query order, but I guess for expressions the normal order makes more sense.

Also it makes more sense to keep it fluent than to put partitionBy(...) into the over invocation as an argument.

timowest added a commit that referenced this issue May 3, 2013
timowest added a commit that referenced this issue May 3, 2013
timowest added a commit that referenced this issue May 7, 2013
timowest added a commit that referenced this issue May 7, 2013
timowest added a commit that referenced this issue May 7, 2013
timowest added a commit that referenced this issue May 10, 2013
@timowest
Copy link
Member

@timowest timowest commented May 27, 2013

Released in 3.2.0

@timowest timowest closed this May 27, 2013
@nyc2
Copy link

@nyc2 nyc2 commented May 29, 2013

Is there a copy&paste feature in SQLTemplates?

    public static final Operator<Object> LEAD = new OperatorImpl<Object>("LAST");

    public static final Operator<Object> LAG = new OperatorImpl<Object>("LAST");
timowest added a commit that referenced this issue May 29, 2013
@timowest
Copy link
Member

@timowest timowest commented May 29, 2013

Fixed

@timowest timowest added this to the 3.2.0 milestone Apr 14, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
4 participants