Aggregates wrapped into set-returning functions give an error
- Dominant language
- C
- Stars
- 12.8k
- Forks
- 794
- Avg merge
- 2d 14h
- Merged PRs (30d)
- 31
Description
The Postgres executor cannot handle set-returning functions in many places. That's why it adds intermediate steps in the plan if a projection contains set-returning functions in `split_pathtarget_at_srfs`.
Unfortunately, we don't follow this logic in the Citus master planner and leave set-returning functions where they are, which causes strange errors when a set-returning function takes an aggregate as a parameter (and possibly in other cases).
```sql
CREATE TABLE test (x int, y int);
SELECT create_distributed_table('test','x');
SELECT unnest(array_agg(y)) FROM test;
ERROR: set-valued function called in context that cannot accept a set
LINE 1: SELECT unnest(array_agg(y)) FROM test;
^
```
Contributor guide
Assessment
This issue has not been assessed yet.