GROUP CUSTOM ... WITHIN ORDER fails in PostgreSQL: the #1700 tiebreak is appended to WITHIN GROUP (ORDER BY ...)
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 45/100
Research direction
Start by reading the OrderGroupProperty change from #1700 and trace how custom aggregates generate ordered calls. Check the PostgreSQL output for the documented percentile_cont example and the BY form. Done when WITHIN GROUP (ORDER BY ...) receives only the specified order expressions and both examples work.
Written by the indexing model from the issue text.
Description
Problem
GROUP CUSTOM ... WITHIN ORDER fails in PostgreSQL on the first read. The example from the GROUP operator documentation:
value = DATA INTEGER (INTEGER);
percentile90() = GROUP CUSTOM NUMERIC[14,2] 'percentile_cont' 0.9 WITHIN ORDER value(INTEGER i);
ERROR: function percentile_cont(numeric, integer, integer) does not exist
The same with BY: GROUP CUSTOM DOUBLE 'percentile_cont' 0.5 WITHIN ORDER sdouble(Store s) BY storeSize(s) gives percentile_cont(numeric, double precision, bigint) does not exist.
Checked on master.
Cause
Since #1700 (c368fb1813) OrderGroupProperty totalizes the order with the inner interfaces when groupType.needsOrderTiebreak(), and for a custom aggregate it returns setOrdered — that is, true exactly for the WITHIN form. The generated call becomes percentile_cont(0.9) WITHIN GROUP (ORDER BY value, i), while ordered-set aggregates (percentile_cont, percentile_disc, ...) take a fixed number of ordered arguments, so the extra column makes the call unresolvable.
The condition looks inverted: for the WITHIN form the tiebreak cannot be added to the call at all, and the result of percentile_cont / percentile_disc does not depend on the order of rows with equal values. In the form without WITHIN (aggrFunc(expr ORDER BY ...), for example string_agg) the order is passed inside the call and does affect the result, and appending the tiebreak there is valid SQL.
Expected
GROUP CUSTOM ... WITHIN ORDER passes only the ORDER expressions to WITHIN GROUP (ORDER BY ...), and the documentation example works.
- Dominant language
- Java
- Stars
- 214
- Forks
- 46
- PR merge metrics
- No merged PRs in 30d
Getting set up
- Ships a Dockerfile or Docker Compose file
- No pull request template
- No contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from lsfusion/platform
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
-
Difficulty 1/5 Under an hour Newbie friendliness 88/100
-
bug
Difficulty 3/5 1-2 days Newbie friendliness 45/100
-
bug
Difficulty 4/5 3-5 days Newbie friendliness 30/100
-
Difficulty 3/5 1-2 days Newbie friendliness 62/100
All issues in lsfusion/platform
Similar issues
-
account assessment course feature lecture
Difficulty 2/5 1-3 hours Newbie friendliness 66/100
Maintainers usually reply within 1 day
-
app:learninggoalhub enhancement good first issue
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
Maintainers usually reply within 1 day
-
Difficulty 1/5 1-3 hours Newbie friendliness 86/100
Maintainers usually reply within 1 day
-
PropertyResolver fails on JDK classes with a non-public field named like the propertyPossibly taken @vaibhavgupta443 claimed this today. Opengood first issue
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
apache/wicket#1991 · 1 comment ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100