UNION pushdown issue when target list ordering is different in subquery
Open
bug
- Dominant language
- C
- Stars
- 12.8k
- Forks
- 794
- Avg merge
- 2d 14h
- Merged PRs (30d)
- 31
Description
We currently look at the query level where a relation exists to understand the partition key index, however this might result in incorrect pushdown, for example:

Here `user_id` has an index of `1` in the subquery, (SELECT user_id, event_id ....).
However in the UNION we have its index as `2`, SELECT event_id, user_id FROM (SELECT .... )
So since Citus looks at the subquery, it thinks that partition key index is 1 in both sides of the UNION, and pushes down the query, which might give incorrect results if there are duplicates.
Contributor guide
Assessment
This issue has not been assessed yet.