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

ARROW-6101: [Rust] [DataFusion] Parallel execution of physical query plan #5111

Closed
wants to merge 13 commits into from

Conversation

andygrove
Copy link
Member

@andygrove andygrove commented Aug 17, 2019

This PR implements parallel query execution, with the ability to create a physical query plan from a logical plan, and call ExecutionContext.collect() to execute the plan and collect the results into a single vector.

This currently only supports trivial projections against partitioned CSV files.

I will create separate PRs to add the other operators (selection, limit, aggregation, etc).

@andygrove andygrove marked this pull request as ready for review September 7, 2019 16:05
@andygrove andygrove changed the title ARROW-6101: [Rust] [DataFusion] Create physical plan from logical plan [DRAFT] ARROW-6101: [Rust] [DataFusion] Parallel execution of physical query plan Sep 7, 2019
@codecov-io
Copy link

Codecov Report

Merging #5111 into master will decrease coverage by 4.86%.
The diff coverage is 80.61%.

Impacted file tree graph

@@             Coverage Diff             @@
##           master    #5111       +/-   ##
===========================================
- Coverage   87.66%   82.79%    -4.87%     
===========================================
  Files        1022       92      -930     
  Lines      146443    25783   -120660     
  Branches     1437        0     -1437     
===========================================
- Hits       128372    21346   -107026     
+ Misses      17709     4437    -13272     
+ Partials      362        0      -362
Impacted Files Coverage Δ
...tafusion/src/execution/physical_plan/datasource.rs 76.92% <76.92%> (ø)
rust/datafusion/src/execution/context.rs 69.83% <81.17%> (+4.38%) ⬆️
python/pyarrow/ipc.pxi
cpp/src/parquet/column_page.h
cpp/src/plasma/test/external_store_tests.cc
cpp/src/arrow/array/builder_decimal.cc
r/src/symbols.cpp
cpp/src/arrow/flight/internal.cc
cpp/src/arrow/compute/compute_test.cc
cpp/src/arrow/python/io.cc
... and 929 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 9fbbc73...7ff8ab7. Read the comment docs.

@nevi-me
Copy link
Contributor

nevi-me commented Sep 8, 2019

Hi @andygrove, I'll catch up on this and other PRs during the week

Copy link
Contributor

@paddyhoran paddyhoran left a comment

Choose a reason for hiding this comment

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

@andygrove I'm not too familiar with the design of datafusion so my review is relatively high level, but overall LGTM.

rust/datafusion/src/execution/context.rs Outdated Show resolved Hide resolved
"Table provider returned no partitions".to_string(),
))
} else {
let partition = partitions[0].lock().unwrap();
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we avoid the unwrap here?

Copy link
Member Author

Choose a reason for hiding this comment

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

In this case, I think we want the unwrap. From https://doc.rust-lang.org/std/sync/struct.Mutex.html:

Most usage of a mutex will simply unwrap() these results, propagating panics among threads to ensure that a possibly invalid invariant is not witnessed.

These queries are now happening on threads, so although a panic here would fail the query, it would not fail the main thread that launched the thread(s) to execute the query.

Ok(Arc::new(exec))
}
}
_ => panic!(),
Copy link
Contributor

Choose a reason for hiding this comment

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

panic should provide some error message

Copy link
Member Author

Choose a reason for hiding this comment

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

Oops. That one was not intentional ... fixed.

rust/datafusion/src/execution/context.rs Outdated Show resolved Hide resolved
.map(|p| {
let p = p.clone();
thread::spawn(move || {
let it = p.execute().unwrap();
Copy link
Contributor

Choose a reason for hiding this comment

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

Again do we need to unwrap here two lines in a row?

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed.

// combine the results from each thread
let mut combined_results: Vec<RecordBatch> = vec![];
for thread in threads {
let result = thread.join().unwrap();
Copy link
Contributor

Choose a reason for hiding this comment

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

unwrap again

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed

@andygrove
Copy link
Member Author

Thanks @paddyhoran. I have addressed the comments, except for the two uses of unwrap when locking mutexes. See my comment above related to that. Let me know what you think.

Copy link
Contributor

@paddyhoran paddyhoran left a comment

Choose a reason for hiding this comment

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

LGTM pending CI

@andygrove
Copy link
Member Author

Travis failure unrelated, so going ahead with merge.

Hit:1 http://apt.postgresql.org/pub/repos/apt xenial-pgdg InRelease
Hit:2 http://archive.ubuntu.com/ubuntu xenial InRelease
Hit:3 http://archive.ubuntu.com/ubuntu xenial-updates InRelease
Hit:4 http://security.ubuntu.com/ubuntu xenial-security InRelease
Hit:5 http://archive.ubuntu.com/ubuntu xenial-backports InRelease
Hit:6 https://apt.llvm.org/xenial llvm-toolchain-xenial-7 InRelease
Get:7 https://packages.microsoft.com/ubuntu/16.04/prod xenial InRelease [3,226 B]
Get:8 https://packages.microsoft.com/ubuntu/16.04/prod xenial/main amd64 Packages [108 kB]
Err:8 https://packages.microsoft.com/ubuntu/16.04/prod xenial/main amd64 Packages
  Hash Sum mismatch
Fetched 112 kB in 0s (132 kB/s)
Reading package lists... Done
E: Failed to fetch https://packages.microsoft.com/ubuntu/16.04/prod/dists/xenial/main/binary-amd64/Packages.gz  Hash Sum mismatch
E: Some index files failed to download. They have been ignored, or old ones used instead.
The command "$TRAVIS_BUILD_DIR/ci/travis_release_test.sh" exited with 100.```

@andygrove andygrove closed this in 28bfd2b Sep 11, 2019
pprudhvi pushed a commit to pprudhvi/arrow that referenced this pull request Sep 16, 2019
…plan

This PR implements parallel query execution, with the ability to create a physical query plan from a logical plan, and call `ExecutionContext.collect()` to execute the plan and collect the results into a single vector.

This currently only supports trivial projections against partitioned CSV files.

I will create separate PRs to add the other operators (selection, limit, aggregation, etc).

Closes apache#5111 from andygrove/ARROW-6101 and squashes the following commits:

b820e69 <Andy Grove> trigger build
0210c70 <Andy Grove> remove an unwrap
d8ff02f <Andy Grove> remove hard-coded batch size, remove comment, remove panic
21e646f <Andy Grove> test passes
dd3cbe6 <Andy Grove> format
104f3ad <Andy Grove> csv provider now supports partitioned csv files
20216bc <Andy Grove> realistic test (failing)
7ff8ab7 <Andy Grove> gmt
5515033 <Andy Grove> unit test works
a292cce <Andy Grove> unit test (currently fails)
63c88d8 <Andy Grove> error handling
42566c3 <Andy Grove> implement collect()
c692217 <Andy Grove> rebase

Authored-by: Andy Grove <[email protected]>
Signed-off-by: Andy Grove <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants