-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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
Improve error message for LISTAGG window function #16982
Comments
Many RDBMS don't support ordering both the aggregate function and the window function. Even without this support, it's still useful to be able to use |
It's not supported in standard SQL, but it makes sense to add support for listagg in a window context at some point. As @lukaseder explained above, the ORDER BY clauses are independent from each other, so there's no overlap. |
Why not? I don't see any such limitation in ISO/IEC 9075-2:2023(E) 6.10 <window function> |
My bad, you're right -- I assumed it was a special case, but it's handled as any of the other aggregation functions. |
@martint based on quick playing with the code (I may be missing something) it looks like adding |
The window ordering is far less useful in this context than the aggregate ordering. I'd say, without aggregate ordering, the What I've seen in most other RDBMS that have difficulties supporting both orderings is that they don't support the window ordering but do support the aggregate ordering of this function. |
building block: #23929 |
Taking a closer look at the SQL spec, I found this in section 9.23:
|
Interesting finding. I had overlooked this line (though I did look at 8) d) ii)...). It does confirm that the aggregate order by clause is more useful than the window order by clause in this context, though I don't see why this limitation needs to be in the standard. The logical semantics of having both orderings seems clear, in my opinion (framing first, aggregation later) |
Indeed. That’s why we’re going to keep this feature as an extension to what the standard allows. |
LISTAGG
currently can't be used as a window function, it seems:This produces:
I think it would be useful to either:
The text was updated successfully, but these errors were encountered: