citusdata / citusdata/citus

UNION pushdown issue when target list ordering is different in subquery

Open
#5,093 0 comments 0 reactions 0 assignees View on GitHub
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:

![image](https://user-images.githubusercontent.com/17179875/124745483-88b23b80-df28-11eb-9087-b867548267fa.png)

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

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.