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/05/07 21:36:54 UTC

[GitHub] [arrow-datafusion] alamb commented on a change in pull request #285: allow datafusion-cli to take file param

alamb commented on a change in pull request #285:
URL: https://github.com/apache/arrow-datafusion/pull/285#discussion_r628545062



##########
File path: datafusion-cli/src/main.rs
##########
@@ -65,16 +77,91 @@ pub async fn main() {
         execution_config = execution_config.with_batch_size(batch_size);
     };
 
-    let mut ctx =
-        ExecutionContext::with_config(execution_config.with_information_schema(true));
+    if let Some(file) = matches
+        .value_of("file")
+        .and_then(|file| File::open(&file).ok())

Review comment:
       I think the use of `ok()` silently ignore errors when opening the file and silently fallback to the repl. This leads to strange behavior for certain files, such as those that that exists, but I don't have permissions to read
   
   For a file such as this, I would expect `datafusion-cli` to generate an error about permissions:
   
   ```
   (arrow_dev) alamb@ip-10-0-0-124:~/Software/arrow-datafusion$ ls -l /tmp/foo.sql 
   --w-------  1 alamb  wheel     0B May  7 17:30 /tmp/foo.sql
   
   (arrow_dev) alamb@ip-10-0-0-124:~/Software/arrow-datafusion$ cat /tmp/foo.sql 
   cat: /tmp/foo.sql: Permission denied
   ```
   
   However, the code on this branch generates no error and instead drops into the interactive REPL loop
   
   ```
   (arrow_dev) alamb@ip-10-0-0-124:~/Software/arrow-datafusion$ ./target/debug/datafusion-cli --file=/tmp/foo.sql
   > 
   
   ```
   




-- 
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.

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