You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by GitBox <gi...@apache.org> on 2021/12/01 05:44:07 UTC

[GitHub] [arrow-datafusion] capkurmagati opened a new pull request #1388: Make cli handle multiple whitespaces

capkurmagati opened a new pull request #1388:
URL: https://github.com/apache/arrow-datafusion/pull/1388


   # Which issue does this PR close?
   The cli cannot handle whitespace like
   ```
   ❯ \?
   '\? ' is not a valid command
   ❯ \quiet true
   '\quiet true ' is not a valid command
   ```
   The PR fixes this issue by removing the consecutive whitespaces.
   <!--
   We generally require a GitHub issue to be filed for all bug fixes and enhancements and this helps us generate change logs for our releases. You can link an issue to this PR using the GitHub syntax. For example `Closes #123` indicates that this PR will close issue #123.
   -->
   
   Closes #.
   
    # Rationale for this change
   <!--
    Why are you proposing this change? If this is already explained clearly in the issue then this section is not needed.
    Explaining clearly why changes are proposed helps reviewers understand your changes and offer better suggestions for fixes.  
   -->
   
   # What changes are included in this PR?
   <!--
   There is no need to duplicate the description in the issue here but it is sometimes worth providing a summary of the individual changes in this PR.
   -->
   
   # Are there any user-facing changes?
   <!--
   If there are user-facing changes then we may require documentation to be updated before approving the PR.
   -->
   
   <!--
   If there are any breaking changes to public APIs, please add the `api change` label.
   -->
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [arrow-datafusion] alamb merged pull request #1388: Make cli handle multiple whitespaces

Posted by GitBox <gi...@apache.org>.
alamb merged pull request #1388:
URL: https://github.com/apache/arrow-datafusion/pull/1388


   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [arrow-datafusion] houqp commented on pull request #1388: Make cli handle multiple whitespaces

Posted by GitBox <gi...@apache.org>.
houqp commented on pull request #1388:
URL: https://github.com/apache/arrow-datafusion/pull/1388#issuecomment-984328748


   eventually, we will need to write a proper lexer and parser for pgcli commands :P 


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [arrow-datafusion] alamb commented on pull request #1388: Make cli handle multiple whitespaces

Posted by GitBox <gi...@apache.org>.
alamb commented on pull request #1388:
URL: https://github.com/apache/arrow-datafusion/pull/1388#issuecomment-985066840


   Thanks @capkurmagati  -- I think this is a small enough fix we can iterate on it if @Jimexist  has some suggestions as well


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [arrow-datafusion] capkurmagati commented on a change in pull request #1388: Make cli handle multiple whitespaces

Posted by GitBox <gi...@apache.org>.
capkurmagati commented on a change in pull request #1388:
URL: https://github.com/apache/arrow-datafusion/pull/1388#discussion_r761126864



##########
File path: datafusion-cli/src/exec.rs
##########
@@ -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(" ");

Review comment:
       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




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [arrow-datafusion] houqp commented on a change in pull request #1388: Make cli handle multiple whitespaces

Posted by GitBox <gi...@apache.org>.
houqp commented on a change in pull request #1388:
URL: https://github.com/apache/arrow-datafusion/pull/1388#discussion_r761393706



##########
File path: datafusion-cli/src/exec.rs
##########
@@ -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(" ");

Review comment:
       oh i see, thanks for the context.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [arrow-datafusion] houqp commented on a change in pull request #1388: Make cli handle multiple whitespaces

Posted by GitBox <gi...@apache.org>.
houqp commented on a change in pull request #1388:
URL: https://github.com/apache/arrow-datafusion/pull/1388#discussion_r760791689



##########
File path: datafusion-cli/src/exec.rs
##########
@@ -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(" ");

Review comment:
       have you tried the trim method? https://doc.rust-lang.org/stable/std/string/struct.String.html#method.trim




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org