From 63c88d8050307e00a707e97c692570aed7de9b10 Mon Sep 17 00:00:00 2001 From: Andy Grove Date: Sat, 7 Sep 2019 09:44:13 -0600 Subject: [PATCH] error handling --- rust/datafusion/src/execution/context.rs | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/rust/datafusion/src/execution/context.rs b/rust/datafusion/src/execution/context.rs index 763d2564cf518..69ba27582dad3 100644 --- a/rust/datafusion/src/execution/context.rs +++ b/rust/datafusion/src/execution/context.rs @@ -279,10 +279,18 @@ impl ExecutionContext { let it = p.execute().unwrap(); let mut it = it.lock().unwrap(); let mut results: Vec = vec![]; - while let Ok(Some(batch)) = it.next() { - results.push(batch); + loop { + match it.next() { + Ok(Some(batch)) => { + results.push(batch); + } + Ok(None) => { + // end of result set + return Ok(results); + } + Err(e) => return Err(e), + } } - Ok(results) }) }) .collect();