ianmcook commented on a change in pull request #9800:
URL: https://github.com/apache/arrow/pull/9800#discussion_r605892693



##########
File path: r/R/dataset-factory.R
##########
@@ -45,15 +45,20 @@ DatasetFactory$create <- function(x,
     return(dataset___UnionDatasetFactory__Make(x))
   }
 
-  path_and_fs <- get_path_and_filesystem(x, filesystem)
-  selector <- FileSelector$create(path_and_fs$path, allow_not_found = FALSE, 
recursive = TRUE)
-
   if (is.character(format)) {
     format <- FileFormat$create(match.arg(format), ...)
   } else {
     assert_is(format, "FileFormat")
   }
 
+  path_and_fs <- get_paths_and_filesystem(x, filesystem)
+  info <- path_and_fs$fs$GetFileInfo(path_and_fs$path)
+
+  if (length(info) > 1 || info[[1]]$type == FileType$File) {
+    # x looks like a vector of one or more file paths (not a directory path)
+    return(FileSystemDatasetFactory$create(path_and_fs$fs, NULL, 
path_and_fs$path, format))
+  }

Review comment:
       We could perform some more thorough checks here, e.g.
   ```r
   if (any(map_lgl(x, ~. == FileType$Directory) {
     stop("...")
   }
   ```
   Or even better we could loop through `info` and check the `$type` of each 
item and give customized messages indicating that it's missing, or it's a 
directory not a file, etc. Is this worth doing?




-- 
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:
us...@infra.apache.org


Reply via email to