From 0210c70f161e315de6627e2edab0797b49058383 Mon Sep 17 00:00:00 2001 From: Andy Grove Date: Tue, 10 Sep 2019 07:43:35 -0600 Subject: [PATCH] remove an unwrap --- rust/datafusion/src/execution/context.rs | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/rust/datafusion/src/execution/context.rs b/rust/datafusion/src/execution/context.rs index 85ba5212b05d5..52b380964f15e 100644 --- a/rust/datafusion/src/execution/context.rs +++ b/rust/datafusion/src/execution/context.rs @@ -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 = vec![]; loop { @@ -306,11 +306,17 @@ impl ExecutionContext { // combine the results from each thread let mut combined_results: Vec = 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)