Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make cli handle multiple whitespaces #1388

Merged
merged 1 commit into from
Dec 2, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion datafusion-cli/src/exec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,8 @@ pub async fn exec_from_repl(ctx: &mut Context, print_options: &PrintOptions) {
match rl.readline("❯ ") {
Ok(line) if line.starts_with('\\') => {
rl.add_history_entry(line.trim_end());
if let Ok(cmd) = &line[1..].parse::<Command>() {
let command = line.split_whitespace().collect::<Vec<_>>().join(" ");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The problem I'd like to fix here is not only leading and trailing whitespaces.
Currently, the behavior is like

DataFusion CLI v5.1.0

❯ \quiet  true
'\quiet  true' is not a valid command
❯ \pset  format  csv
'\pset  format  csv' is not a valid command
❯ \pset format  csv
Execution error:  csv is not a valid format type [possible values: csv, tsv, table, json, ndjson]

Without normalizing whitespaces before parsing commands, every command need to do trim like here.
https://github.com/apache/arrow-datafusion/blob/42f8ab1e44510cea73f9eb2300d28f2fa92ac55a/datafusion-cli/src/functions.rs#L159

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh i see, thanks for the context.

if let Ok(cmd) = &command[1..].parse::<Command>() {
match cmd {
Command::Quit => break,
_ => {
Expand Down