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

Comments

Projects
None yet
4 participants
@simpleisbest

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

This comment has been minimized.

Show comment
Hide comment
@timowest

timowest May 2, 2013

Member

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)
Member

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

This comment has been minimized.

Show comment
Hide comment
@lukaseder

lukaseder May 2, 2013

Beautiful API design choice ;-)

Beautiful API design choice ;-)

@timowest

This comment has been minimized.

Show comment
Hide comment
@timowest

timowest May 2, 2013

Member

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.

Member

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

This comment has been minimized.

Show comment
Hide comment
@timowest

timowest May 27, 2013

Member

Released in 3.2.0

Member

timowest commented May 27, 2013

Released in 3.2.0

@timowest timowest closed this May 27, 2013

@nyc2

This comment has been minimized.

Show comment
Hide comment
@nyc2

nyc2 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");

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

This comment has been minimized.

Show comment
Hide comment
@timowest

timowest May 29, 2013

Member

Fixed

Member

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