mustafasrepo opened a new pull request, #8626:
URL: https://github.com/apache/arrow-datafusion/pull/8626
<!--
Before opening a PR. Make sure following points are double-checked
-- Make sure `cargo fmt` is done.
-- Make sure `bash dev/rust_lint.sh` successfully runs.
-- Make sure `cargo test` passes from all tests.
-- Make sure there are wide-ranging unit tests, integration tests,
end-to-end tests for the added functionality.
-- Make sure there is no merge conflict with target branch.
-- If there are sections in the code, that can be written as function do so
Especially, if these sections are
- occur multiple times,
- line number is more than > 20 approximately.
-- The code added doesn't contain unnecessary `.clone`s.
-- The code added doesn't contain naked `unwrap`s.
-- Make sure imports are consistent. Imports should be in following order
- Standart library imports (alphabetically ordered within this group)
- Arrow/ Datafusion imports (alphabetically ordered within this group)
- #rd Party libraries (alphabetically ordered within this group)
where each group is seperated by an empty line.
-- Inspect your attributes to what needs to be public, do not expose
something if it is not used elsewhere.
-- Make sure that the docstrings of the newly added code blocks are not
missing.
-- Read through comments whether they are clear, and grammatically correct.
-- Look for whether for loops can be re-written as iterator. Be
pro-functional style.
-- Do not use short names such as `res`, `elem`, instead use `result`,
`item`, etc.
-- For short and common functions use namespace with it to be explicit.
(such as instead of `min`, `max`, use `std::cmp::min`, `std::cmp::max`
etc.)
-- Add necessary license notice for the added code that will remain in the
Synnada repo.
-- Make sure the PR body is understandable and summarizes the topic well.
-- You can use CHATGPT to convert code to idimatic style, to generate
documentation.
-->
## Which issue does this PR close?
<!--
We generally require a GitHub issue to be filed for all bug fixes and
enhancements and this helps us generate change logs for our releases. You can
link an issue to this PR using the GitHub syntax. For example `Closes #123`
indicates that this PR will close issue #123.
-->
Closes #.
## Rationale for this change
Current filters are not pushed down to the cross join (equality predicates
are pushed down). For this reason we generate following plan for the query
```sql
SELECT *
FROM annotated_data as l, annotated_data as r
WHERE l.a > r.a
```
```sql
FilterExec: filter=a@0 > a@1
--CrossJoinExec:
----RepartitionExec: partitioning=RoundRobinBatch(2), input_partitions=1
------CsvExec: file_groups={1 group:
[[WORKSPACE_ROOT/datafusion/core/tests/data/window_2.csv]]}, projection=[a0, a,
b, c, d], output_ordering=[a@1 ASC, b@2 ASC NULLS LAST, c@3 ASC NULLS LAST],
has_header=true
----CsvExec: file_groups={1 group:
[[WORKSPACE_ROOT/datafusion/core/tests/data/window_2.csv]]}, projection=[a0, a,
b, c, d], output_ordering=[a@1 ASC, b@2 ASC NULLS LAST, c@3 ASC NULLS LAST],
has_header=true
```
However, if we were to pushdown filter into CrossJoin (by converting it into
inner join with filter condition ) we could have produced following plan
```sql
NestedLoopJoinExec: join_type=Inner, filter=a@0 > a@1
--RepartitionExec: partitioning=RoundRobinBatch(2), input_partitions=1
----CsvExec: file_groups={1 group:
[[WORKSPACE_ROOT/datafusion/core/tests/data/window_2.csv]]}, projection=[a0, a,
b, c, d], output_ordering=[a@1 ASC, b@2 ASC NULLS LAST, c@3 ASC NULLS LAST],
has_header=true
--CsvExec: file_groups={1 group:
[[WORKSPACE_ROOT/datafusion/core/tests/data/window_2.csv]]}, projection=[a0, a,
b, c, d], output_ordering=[a@1 ASC, b@2 ASC NULLS LAST, c@3 ASC NULLS LAST],
has_header=true
```
which would be more memory efficient especially in large tables. This PR
adds this support
<!--
Why are you proposing this change? If this is already explained clearly in
the issue then this section is not needed.
Explaining clearly why changes are proposed helps reviewers understand your
changes and offer better suggestions for fixes.
-->
## What changes are included in this PR?
<!--
There is no need to duplicate the description in the issue here but it is
sometimes worth providing a summary of the individual changes in this PR.
-->
## Are these changes tested?
Yes
<!--
We typically require tests for all PRs in order to:
1. Prevent the code from being accidentally broken by subsequent changes
2. Serve as another way to document the expected behavior of the code
If tests are not included in your PR, please explain why (for example, are
they covered by existing tests)?
-->
## Are there any user-facing changes?
<!--
If there are user-facing changes then we may require documentation to be
updated before approving the PR.
-->
<!--
If there are any breaking changes to public APIs, please add the `api
change` label.
-->
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]