Recursive planner should pushdown filters into the recursively planned queries
- Dominant language
- C
- Stars
- 12.8k
- Forks
- 794
- Avg merge
- 2d 14h
- Merged PRs (30d)
- 31
Description
As an example, look at the following query. The filter ` ANY(ARRAY[2, 1, 6])` on the outer query is safe to pushdown to the subquery before it is recursively planned
```SQL
SELECT count(*)
FROM users_table u1
JOIN
(SELECT value_1,
random()
FROM users_table) AS u2 USING (value_1)
WHERE u2.value_1 > ANY(ARRAY[2, 1, 6]);
```
Currently produces the following query:
```SQL
SELECT value_1, random() AS random FROM sc1.users_table_102396 users_table WHERE true
```
However, it should be safe to do
```SQL
SELECT value_1, random() AS random FROM sc1.users_table_102396 users_table WHERE users_table.value_1 > ANY(ARRAY[2, 1, 6]);
```
A basic prototype: https://github.com/citusdata/citus/pull/2504/commits/3ac4c1c3a2d59213133ec0f47b585ad4c6a5bce6 and some tests: https://github.com/citusdata/citus/pull/2504/commits/6b2a412c12d885e01bc5ec4ab0577e5b6a507cbd
Contributor guide
Assessment
This issue has not been assessed yet.