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

Feature/sort enforcement refactor #5228

Merged
merged 5 commits into from
Feb 13, 2023
Merged

Feature/sort enforcement refactor #5228

merged 5 commits into from
Feb 13, 2023

Conversation

mustafasrepo
Copy link
Contributor

Which issue does this PR close?

Closes #.

Rationale for this change

As suggested by @mingmwang in the discussion. Comparing ordering between schemas when there are multiple executors in between them may produce incorrect results. Although this situation may not arise in practice with the current ordering of the optimization rules. We have changed the implementation in case one encounters it (Nobody knows).

What changes are included in this PR?

With this change parallelize sort rule compares the immediate table for converting Coalesce + Executors that do not require SingleDistribution + Sort cascades to Executors that do not require SingleDistribution + Sort + SortPreservingMerge cascade.
We also added a check that the final Sort in the cascade rule is actually a Global sort.

Are these changes tested?

We added a unit test to verify that rule only ends when Sort is a global sort. Also, the existing test checks the sort comparison is done between immediate executors.

Are there any user-facing changes?

@github-actions github-actions bot added the core Core DataFusion crate label Feb 9, 2023
@ozankabak
Copy link
Contributor

ozankabak commented Feb 9, 2023

For context, this is the first follow-on PR to address one of the minor issues that were discussed in the original PR (#5171). @mingmwang, PTAL. Thanks!

Copy link
Contributor

@alamb alamb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not an expert in this code, so I would really like @mingmwang to review as well prior to merge.

However, I went over the plan changes and new test and they all make sense to me and the fact that the existing tests all pass means I am 👍 for this PR.

Thank you @mustafasrepo

cc @crepererum who may also be interested in this PR as we are reworking some of our plan construction in IOx as well

Comment on lines +1781 to +1783
" RepartitionExec: partitioning=RoundRobinBatch(10), input_partitions=10",
" RepartitionExec: partitioning=RoundRobinBatch(10), input_partitions=0",
" MemoryExec: partitions=0, partition_sizes=[]",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This plan definitely looks better than the input.

" FilterExec: NOT non_nullable_col@1",
" SortExec: [nullable_col@0 ASC]",
" SortExec: [nullable_col@0 ASC]",
" FilterExec: NOT non_nullable_col@1",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This plan change looks better to me as well (do filtering before sort)

@mingmwang
Copy link
Contributor

I will review this PR carefully today.

@mingmwang
Copy link
Contributor

The change LGTM.

@alamb alamb merged commit 9565887 into apache:master Feb 13, 2023
@alamb
Copy link
Contributor

alamb commented Feb 13, 2023

Thanks @mustafasrepo @mingmwang and @ozankabak 🚀

@ursabot
Copy link

ursabot commented Feb 13, 2023

Benchmark runs are scheduled for baseline = 3da7902 and contender = 9565887. 9565887 is a master commit associated with this PR. Results will be available as each benchmark for each run completes.
Conbench compare runs links:
[Skipped ⚠️ Benchmarking of arrow-datafusion-commits is not supported on ec2-t3-xlarge-us-east-2] ec2-t3-xlarge-us-east-2
[Skipped ⚠️ Benchmarking of arrow-datafusion-commits is not supported on test-mac-arm] test-mac-arm
[Skipped ⚠️ Benchmarking of arrow-datafusion-commits is not supported on ursa-i9-9960x] ursa-i9-9960x
[Skipped ⚠️ Benchmarking of arrow-datafusion-commits is not supported on ursa-thinkcentre-m75q] ursa-thinkcentre-m75q
Buildkite builds:
Supported benchmarks:
ec2-t3-xlarge-us-east-2: Supported benchmark langs: Python, R. Runs only benchmarks with cloud = True
test-mac-arm: Supported benchmark langs: C++, Python, R
ursa-i9-9960x: Supported benchmark langs: Python, R, JavaScript
ursa-thinkcentre-m75q: Supported benchmark langs: C++, Java

jiangzhx pushed a commit to jiangzhx/arrow-datafusion that referenced this pull request Feb 24, 2023
* Remove multilayer chain Ordering comparison for sort parallelize rule

* Update tree code

* Simplify if condition

* Update test

* Simplify sort insertion utility to avoid clones

---------

Co-authored-by: Mehmet Ozan Kabak <ozankabak@gmail.com>
@mustafasrepo mustafasrepo deleted the feature/sort_enforcement_refactor branch March 2, 2023 12:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core Core DataFusion crate
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants