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

   ### Describe the bug
   
   This should not work:
   
   ```sql
   > select sum(num) within group (order by num) from 
'/Users/jeffrey/Downloads/test.csv';
   
+------------------------------------------------------------------------------------------------------------+
   | sum(/Users/jeffrey/Downloads/test.csv.num) ORDER BY 
[/Users/jeffrey/Downloads/test.csv.num ASC NULLS LAST] |
   
+------------------------------------------------------------------------------------------------------------+
   | 750                                                                        
                                |
   
+------------------------------------------------------------------------------------------------------------+
   1 row(s) fetched.
   Elapsed 0.011 seconds.
   ```
   
   `WITHIN GROUP` should be allowed only for ordered set aggregate functions 
(see #12824)
   
   Postgres for reference:
   
   ```sql
   postgres=# select sum(salary) within group (order by salary) from employees;
   ERROR:  function sum(numeric, numeric) does not exist
   LINE 1: select sum(salary) within group (order by salary) from emplo...
                  ^
   HINT:  No function matches the given name and argument types. You might need 
to add explicit type casts.
   postgres=# select sum() within group (order by salary) from employees;
   ERROR:  sum is not an ordered-set aggregate, so it cannot have WITHIN GROUP
   LINE 1: select sum() within group (order by salary) from employees;
   ```
   
   ### To Reproduce
   
   _No response_
   
   ### 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