Skip to content

Cannot use column positions in GROUP BY

This should work similarly to ORDER BY <position> (as it does in PostgreSQL):

postgres=# select relname as name from pg_class group by 1 limit 1;
┌───────────────────────────┐
           name            
├───────────────────────────┤
 _pg_foreign_data_wrappers 
└───────────────────────────┘
(1 row)

postgres=# select relname as name from pg_class group by 10 limit 1;
ERROR:  GROUP BY position 10 is not in select list
LINE 1: select relname as name from pg_class group by 10 limit 1;
                                                      ^

Repro:

picodata> select name from _pico_table group by 1;
---
- null
- 'sbroad: invalid query: grouping expression must contain at least one column. Invalid
  expression number: 0'
...
Edited by Dmitry Ivanov