Skip to content

Commit

Permalink
remove an unwrap
Browse files Browse the repository at this point in the history
  • Loading branch information
andygrove committed Sep 10, 2019
1 parent d8ff02f commit 0210c70
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions rust/datafusion/src/execution/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ impl ExecutionContext {
.map(|p| {
let p = p.clone();
thread::spawn(move || {
let it = p.execute().unwrap();
let it = p.execute()?;
let mut it = it.lock().unwrap();
let mut results: Vec<RecordBatch> = vec![];
loop {
Expand All @@ -306,11 +306,17 @@ impl ExecutionContext {
// combine the results from each thread
let mut combined_results: Vec<RecordBatch> = vec![];
for thread in threads {
let result = thread.join().unwrap();
let result = result?;
result
.iter()
.for_each(|batch| combined_results.push(batch.clone()));
match thread.join() {
Ok(result) => {
let result = result?;
result
.iter()
.for_each(|batch| combined_results.push(batch.clone()));
}
Err(_) => {
return Err(ExecutionError::General("Thread failed".to_string()))
}
}
}

Ok(combined_results)
Expand Down

0 comments on commit 0210c70

Please sign in to comment.