citusdata / citusdata/citus

Aggregates wrapped into set-returning functions give an error

Open
#2,265 2 comments 1 reaction 0 assignees View on GitHub
bug
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

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.