Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pushdown filters that do not reference unested columns #11016

Closed
alamb opened this issue Jun 19, 2024 · 1 comment · Fixed by #11019
Closed

Pushdown filters that do not reference unested columns #11016

alamb opened this issue Jun 19, 2024 · 1 comment · Fixed by #11019

Comments

@alamb
Copy link
Contributor

alamb commented Jun 19, 2024

Maybe we can push down the part of the predicate that does not contain exec_columns?
For example in query

select ua from (select unnest(a) as ua, 1 as b from t) where ua > 3 and b > 1;

We can push down b > 1.

Originally posted by @jonahgao in #10991 (review)

@alamb
Copy link
Contributor Author

alamb commented Jun 19, 2024

This PR adds a test: #11017

# Could push the filter (column1 = 2) down below unnest
# https://github.com/apache/datafusion/issues/11016
query TT
explain select uc2, column1 from  (select unnest(column2) as uc2, column1 from v) where uc2 > 3 AND column1 = 2;
----
logical_plan
01)Projection: unnest(v.column2) AS uc2, v.column1
02)--Filter: unnest(v.column2) > Int64(3) AND v.column1 = Int64(2)
03)----Unnest: lists[unnest(v.column2)] structs[]
04)------Projection: v.column2 AS unnest(v.column2), v.column1
05)--------TableScan: v projection=[column1, column2]

The plan could look something like this

logical_plan
01)Projection: unnest(v.column2) AS uc2, v.column1
02)--Filter: unnest(v.column2) > Int64(3)
03)----Unnest: lists[unnest(v.column2)] structs[]
04)------Projection: v.column2 AS unnest(v.column2), v.column1
05)--------Filter: v.column1 = Int64(2)    <-- Note this filter is pushed down
06)----------TableScan: v projection=[column1, column2]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant