[ 
https://issues.apache.org/jira/browse/ARROW-17761?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Alex Deng updated ARROW-17761:
------------------------------
    Description: 
When reading from s3 failed, the error message user get is 

```
Error in url(file, open = "rb") : URL scheme unsupported by this method
 ```
The reason is in arrow:::make_readable_file, the code tries to create a 
filesystem from path and if this step failed, it tries to run is_url which 
doesn't supports s3. s3 reading can fail due to many reasons, from auth to s3 
path doesn't exist. The request is to make the error message more useful. 

 

```
if (inherits(file, "SubTreeFileSystem")) {
filesystem <- file$base_fs
path <- sub("/$", "", file$base_path)
file <- filesystem$OpenInputFile(path)
}
else if (is.string(file)) {
if (is_url(file)) {
file <- tryCatch(

{ fs_and_path <- FileSystem$from_uri(file) 
fs_and_path$fs$OpenInputFile(fs_and_path$path) }

, error = function(e) {
MakeRConnectionInputStream(url(file, open = "rb"))
})
}

```

  was:
When reading from s3 failed, the error message user get is 
Error in url(file, open = "rb") : URL scheme unsupported by this metho
 
The reason is in arrow:::make_readable_file, the code tries to create a 
filesystem from path and if this step failed, it tries to run is_url which 
doesn't supports s3. s3 reading can fail due to many reasons, from auth to s3 
path doesn't exist. The request is to make the error message more useful. 
   if (inherits(file, "SubTreeFileSystem")) \{
        filesystem <- file$base_fs
        path <- sub("/$", "", file$base_path)
        file <- filesystem$OpenInputFile(path)
    }
    else if (is.string(file)) \{
        if (is_url(file)) {
            file <- tryCatch({
                fs_and_path <- FileSystem$from_uri(file)
                fs_and_path$fs$OpenInputFile(fs_and_path$path)
            }, error = function(e) \{
                MakeRConnectionInputStream(url(file, open = "rb"))
            })
        }


> R arrow::read_parquet shows misleading message about url scheme when reading 
> from s3 failed
> -------------------------------------------------------------------------------------------
>
>                 Key: ARROW-17761
>                 URL: https://issues.apache.org/jira/browse/ARROW-17761
>             Project: Apache Arrow
>          Issue Type: Improvement
>          Components: R
>            Reporter: Alex Deng
>            Priority: Minor
>
> When reading from s3 failed, the error message user get is 
> ```
> Error in url(file, open = "rb") : URL scheme unsupported by this method
>  ```
> The reason is in arrow:::make_readable_file, the code tries to create a 
> filesystem from path and if this step failed, it tries to run is_url which 
> doesn't supports s3. s3 reading can fail due to many reasons, from auth to s3 
> path doesn't exist. The request is to make the error message more useful. 
>  
> ```
> if (inherits(file, "SubTreeFileSystem")) {
> filesystem <- file$base_fs
> path <- sub("/$", "", file$base_path)
> file <- filesystem$OpenInputFile(path)
> }
> else if (is.string(file)) {
> if (is_url(file)) {
> file <- tryCatch(
> { fs_and_path <- FileSystem$from_uri(file) 
> fs_and_path$fs$OpenInputFile(fs_and_path$path) }
> , error = function(e) {
> MakeRConnectionInputStream(url(file, open = "rb"))
> })
> }
> ```



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to