This is an automated email from the ASF dual-hosted git repository.
jiayuliu pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/arrow-datafusion.git
The following commit(s) were added to refs/heads/master by this push:
new a4bd240 datafusion cli to handle EoF and interrupt signal (#1225)
a4bd240 is described below
commit a4bd240697280911cb70bf1ffeeff973f29c0b59
Author: Jiayu Liu <[email protected]>
AuthorDate: Thu Nov 4 09:28:39 2021 +0800
datafusion cli to handle EoF and interrupt signal (#1225)
---
datafusion-cli/src/exec.rs | 12 +++++++++++-
1 file changed, 11 insertions(+), 1 deletion(-)
diff --git a/datafusion-cli/src/exec.rs b/datafusion-cli/src/exec.rs
index f22e5cc..349c2d3 100644
--- a/datafusion-cli/src/exec.rs
+++ b/datafusion-cli/src/exec.rs
@@ -26,6 +26,7 @@ use crate::{
use datafusion::arrow::record_batch::RecordBatch;
use datafusion::arrow::util::pretty;
use datafusion::error::{DataFusionError, Result};
+use rustyline::error::ReadlineError;
use rustyline::Editor;
use std::fs::File;
use std::io::prelude::*;
@@ -114,7 +115,16 @@ pub async fn exec_from_repl(ctx: &mut Context,
print_options: &PrintOptions) {
query.push_str(&line);
query.push('\n');
}
- Err(_) => {
+ Err(ReadlineError::Interrupted) => {
+ println!("^C");
+ continue;
+ }
+ Err(ReadlineError::Eof) => {
+ println!("\\q");
+ break;
+ }
+ Err(err) => {
+ eprintln!("Unknown error happened {:?}", err);
break;
}
}