tustvold commented on code in PR #4525:
URL: https://github.com/apache/arrow-datafusion/pull/4525#discussion_r1041117868


##########
datafusion/core/src/datasource/listing/url.rs:
##########
@@ -99,10 +99,14 @@ impl ListingTableUrl {
         };
 
         let path = std::path::Path::new(prefix).canonicalize()?;
-        let url = match path.is_file() {
-            true => Url::from_file_path(path).unwrap(),
-            false => Url::from_directory_path(path).unwrap(),
-        };
+        let url = if path.is_dir() {
+            Url::from_directory_path(path)
+        } else {
+            Url::from_file_path(path)
+        }
+        .map_err(|_| DataFusionError::Internal(format!("Can not open path: 
{}", s)))?;

Review Comment:
   > To support all kinds of readable files, one typically checks with 
!is_dir(). You can get more context here at this clippy discussion.
   
   Makes sense, thank you
   
   > However, if you believe it reduces readability, we can go back to unwrap.
   
   I think it does, but I don't feel especially strongly :sweat_smile: . There 
are long term plans to revisit the error handling to use something like anyhow, 
which will clean this all up



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to