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 FILTER emulation with Oracle's KEEP syntax #16591

Open
lukaseder opened this issue Apr 24, 2024 · 0 comments
Open

Support FILTER emulation with Oracle's KEEP syntax #16591

lukaseder opened this issue Apr 24, 2024 · 0 comments

Comments

@lukaseder
Copy link
Member

lukaseder commented Apr 24, 2024

This hypothetical syntax should work with jOOQ:

select sum(x) 
  filter (where z != 1)
  keep (dense_rank first order by y) 
from t

It currently doesn't parse:

Keyword 'SELECT' expected: [3:9] select sum(x) 
  filter (where z != 1)
  keep ([*]dense_rank first order by y) 
from t

So, let's get this to work as well. Once it works it should be emulated as follows:

select sum(case when z <> 1 then x end)
  keep (dense_rank first order by case when z <> 1 then y end nulls last)
from t

It currently produces this emulation, though, which is "wrong" (or let's say, less useful):

select sum(case when z <> 1 then x end)
  keep (dense_rank first order by y)
from t

The FILTER should apply also to the KEEP clause.

This is a backwards incompatible change. I'm not 100% convinced we should implement it, yet. Specifically, because in jOOQ, the keepDenseRankFirst() clause is appended to the AggregateFunction first, before the filterWhere() clause, which hints at the current implementation being correct.

But at least it's documented now as a tempting change, which can be discussed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

1 participant