Skip to content

WITHIN GROUP needs to be more strict #18109

@Jefffrey

Description

@Jefffrey

Describe the bug

This should not work:

> 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:

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

See these comments:

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions