Skip to content

Apache DataFusion SQL Query Engine

Minor: Prevent empty datafusion-cli commands (#10219)

compheadb9f17b030d9f
diff --git a/datafusion-cli/src/main.rs b/datafusion-cli/src/main.rs
index 38537dbd92..6f71ccafb7 100644
--- a/datafusion-cli/src/main.rs
+++ b/datafusion-cli/src/main.rs
@@ -83,7 +83,8 @@ struct Args {
short = 'c',
long,
multiple_values = true,
- help = "Execute the given command string(s), then exit"
+ help = "Execute the given command string(s), then exit. Commands are expected to be non empty.",
+ validator(is_valid_command)
)]
command: Vec<String>,
@@ -285,6 +286,14 @@ fn is_valid_memory_pool_size(size: &str) -> Result<(), String> {
}
}
+fn is_valid_command(command: &str) -> Result<(), String> {
+ if !command.is_empty() {
+ Ok(())
+ } else {
+ Err("-c flag expects only non empty commands".to_string())
+ }
+}
+
#[derive(Debug, Clone, Copy)]
enum ByteUnit {
Byte,