Introduce ordered set aggregate functions #4127
Replies: 1 comment
-
|
See #4758 |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
The idea is to extend HQL to accept the syntax
function_name(DISTINCT? args*) WITHIN GROUP (ORDER BY ...)for functions that are ordered set aggregate functions. Here is a nice explanation of ordered set aggregate functions and specifically, the interestinglistaggvariant for which we need a special grammar rule because it also has anON OVERFLOWclause: https://modern-sql.com/feature/listaggThe emulation of the
listaggfunction can easily be done on most databases through the use of the various vendor specific versions e.g.string_aggandgroup_concat. Emulating the function with a recursive CTE is also possible but probably not practical, so for databases that do not support this function, we should simply provide an error.Out of the databases that we have in hibernate-core (the others are now in hibernate-community-dialects), the following databases do not support the string aggregation:
It might be possible to implement UDFs to emulate this function, but that is out of scope.
Apart from the standard
listaggfunction, I propose we also add the following functions (without emulation, at least for now) which are nicely explained in the PostgreSQL documentation (https://www.postgresql.org/docs/13/functions-aggregate.html#FUNCTIONS-ORDEREDSET-TABLE):modepercentile_contpercentile_discAnd the following hypothetical set aggregate functions (https://www.postgresql.org/docs/13/functions-aggregate.html#FUNCTIONS-HYPOTHETICAL-TABLE):
rankdense_rankpercent_rankcume_distBeta Was this translation helpful? Give feedback.
All reactions