xtimbeau opened a new issue, #40624:
URL: https://github.com/apache/arrow/issues/40624

   ### Describe the bug, including details regarding any error messages, 
version, and platform.
   
   Building datasets from folders, subfolders and parquet files can make R 
arrow crashes:
   
   Here is the reprex (run the 3 tests separatly):
   
   ```r
   # test one hive field in parquet and folder name crashes --------
   library(tidyverse) 
   data <- tibble(
     x = 1:10,
     g = floor(0:9/5))
   if(fs::file_exists("/tmp/test")) fs::dir_delete("/tmp/test")
   # building subfolders
   walk(0:1, ~{
     dd <- data |> filter(g==.x)
     fn <- str_c("/tmp/test/g=", .x, "/part-0.parquet")
     fs::dir_create(str_c("/tmp/test/g=", .x))
     arrow::write_parquet(dd, fn)})
   arrow::open_dataset("/tmp/test/g=1") |> collect() # ok
   arrow::open_dataset("/tmp/test/g=0") |> collect() # ok
   arrow::open_dataset("/tmp/test/")  |> collect()  # crashes
   
   # test two hive field in parquet and not in folder name ok --------
   library(tidyverse) 
   data <- tibble(
     x = 1:10,
     g = floor(0:9/5))
   if(fs::file_exists("/tmp/test")) fs::dir_delete("/tmp/test")
   walk(0:1, ~{
     dd <- data |> filter(g==.x)
     fn <- str_c("/tmp/test/", .x, "/part-0.parquet")
     fs::dir_create(str_c("/tmp/test/", .x))
     arrow::write_parquet(dd, fn)})
   arrow::open_dataset("/tmp/test/1") |> collect() # pass
   arrow::open_dataset("/tmp/test/0") |> collect() # pass
   arrow::open_dataset("/tmp/test/")  |> collect()  # pass
   
   # test three hive field not in parquet but in folder name ok --------
   library(tidyverse) 
   data <- tibble(
     x = 1:10,
     g = floor(0:9/5))
   if(fs::file_exists("/tmp/test")) fs::dir_delete("/tmp/test")
   walk(0:1, ~{
     dd <- data |> filter(g==.x) |> select(-g)
     fn <- str_c("/tmp/test/g=", .x, "/part-0.parquet")
     fs::dir_create(str_c("/tmp/test/g=", .x))
     arrow::write_parquet(dd, fn)})
   arrow::open_dataset("/tmp/test/g=1") |> collect() # pass
   arrow::open_dataset("/tmp/test/g=0") |> collect() # pass
   arrow::open_dataset("/tmp/test/")  |> collect() # pass
   ```
   
   Using arrow 15.0.1, MacOS 14.4, RStudio, R 4.3.3
   
   
   ### Component(s)
   
   R


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