Describe the bug
Inline ORDER BY handling unconditionally removes the first aggregate argument.
This breaks approx_percentile_cont, where the first argument is the percentile rather than the ordered value.
To Reproduce
CREATE TABLE aggregate_test_repro AS
SELECT c1, c3
FROM (
VALUES
('a', CAST(10 AS DOUBLE)),
('a', CAST(20 AS DOUBLE)),
('b', CAST(30 AS DOUBLE))
) AS t(c1, c3);
SELECT c1, approx_percentile_cont(0.95, 200 ORDER BY c3)
FROM aggregate_test_repro
GROUP BY c1;
The query fails with:
Percentile value must be between 0.0 and 1.0 inclusive, 200 is invalid
The weighted variant also loses its weight argument:
approx_percentile_cont_with_weight(1, 0.95 ORDER BY c3)
Expected behavior
No response
Additional context
No response
Describe the bug
Inline
ORDER BYhandling unconditionally removes the first aggregate argument.This breaks
approx_percentile_cont, where the first argument is the percentile rather than the ordered value.To Reproduce
The query fails with:
The weighted variant also loses its weight argument:
Expected behavior
No response
Additional context
No response