haohuaijin opened a new issue, #24410:
URL: https://github.com/apache/datafusion/issues/24410

   ### 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
   
   ```sql
   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);
   ```
   
   ```sql
   SELECT c1, approx_percentile_cont(0.95, 200 ORDER BY c3)
   FROM aggregate_test_repro
   GROUP BY c1;
   ```
   
   The query fails with:
   
   ```text
   Percentile value must be between 0.0 and 1.0 inclusive, 200 is invalid
   ```
   
   The weighted variant also loses its weight argument:
   
   ```sql
   approx_percentile_cont_with_weight(1, 0.95 ORDER BY c3)
   ```
   
   ### Expected behavior
   
   _No response_
   
   ### Additional context
   
   _No response_


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to