Repository navigation
Closed
Description
library(tidyverse)
library(arrow)
car_info <- rownames_to_column(mtcars, "car_info")
cars_arrow_table <- arrow_table(car_info)
other_mtcars_data <- select(car_info, 1) %>%
mutate(main_color = sample( c("red", "blue", "white", "black"), size = n(), replace = TRUE)) %>%
arrow::arrow_table()
temp <- tempdir()
par_temp <- paste0(temp, "\\parquet")
car_info %>% arrow::write_dataset(par_temp)
cars_arrow <- arrow::open_dataset(par_temp)
# using arrow tables works ------------------------------------------------------
cars_arrow_table %>% left_join(other_mtcars_data) %>% count(main_color) %>% collect()
# using open dataset crashes R ------------------------------------------------------------------
other_mtcars_data %>%
left_join(cars_arrow) %>%
count(main_color) %>%
collect()
#other variation also crash
cars_arrow %>%
left_join(other_mtcars_data) %>%
count(main_color) %>%
collect()
cars_arrow %>%
left_join(other_mtcars_data) %>%
group_by(main_color) %>%
summarise(n = n()) %>%
collect()
#compute also crashes
cars_arrow %>%
left_join(other_mtcars_data) %>%
count(main_color) %>%
compute()
# workaround with duckdb ------------------------------------------------------
##this works
cars_duck <- to_duckdb(cars_arrow, auto_disconnect = TRUE)
other_cars_duck <- to_duckdb(other_mtcars_data, auto_disconnect = TRUE)
cars_duck %>%
left_join(other_cars_duck) %>%
count(main_color) %>%
collect()
##this doesn't (don't know if expected to work actually)
cars_arrow %>%
left_join(other_mtcars_data) %>%
to_duckdb() Environment: R version 4.0.4
Reporter: Will Jones / @wjones127
Assignee: Will Jones / @wjones127
Related issues:
- [R] Problem with Join in apache arrow in R (is duplicated by)
- [R] Joining two datasets crashes if use_threads=FALSE (relates to)
PRs and other links:
Note: This issue was originally created as ARROW-14908. Please see the migration documentation for further details.
Activity
asfimport commentedon Nov 29, 2021
Neal Richardson / @nealrichardson:
Can you install the latest patch release (6.0.1)? These all work for me on that version.
asfimport commentedon Nov 29, 2021
Fabio Machado:
I installed the CRAN 6.0.1 version but I'm still getting crashes.
asfimport commentedon Nov 29, 2021
Neal Richardson / @nealrichardson:
Ok, can you provide sessionInfo() and any other system details?
asfimport commentedon Nov 29, 2021
Fabio Machado:
Here's the sessionInfo()
asfimport commentedon Jan 13, 2022
Jeanette Clark:
I am seeing similar issues (but without the summarize). The crash only occurs after the join, filtering, and even collecting the entire (large) table works fine. Example I was working off of and session info are below.
asfimport commentedon Jan 14, 2022
Neal Richardson / @nealrichardson:
Other angles
[~jclark]and I explored:asfimport commentedon Jan 14, 2022
Will Jones / @wjones127:
[~jclark]thanks for that example repro. I get a crash just like you said in Arrow 6.0.0 (but don't on my Mac). I also tried in the dev version of Arrow, and instead get the following error:Looking at the traceback from the Arrow 6 crash it's not immediately obvious that it's the same error as above, but I will continue to look deeper.
asfimport commentedon Feb 9, 2022
Will Jones / @wjones127:
I've made some progress, but not yet found a fix. This issue isn't strictly linked to the Windows platform; instead it has do to with the setting
options(arrow.use_threads = FALSE), which it doesn't seem the join implementation anticipated. That setting is FALSE on Windows by default, but TRUE on other platforms. I can reproduce this issue on Mac OS by setting it to FALSE.Note that I can get the example to work on Windows by setting
options(arrow.use_threads = TRUE), so that may be a viable workaround in some cases. However, other issues have been reported on Windows with the use_threads option, which is why it has been turned off for now on Windows.asfimport commentedon Feb 14, 2022
Sam Albers / @boshek:
Some additional break crumbs. The examples (run on windows 10, with arrow 7.0.0) are wrapped in reprex::reprex because it catches the R crash nicely.
works by specifying join column
doesn't work when one of the joins dfs is in memory
doesn't work when join column in not specified
doesn't work join column is specified by that column is the partition
asfimport commentedon Feb 14, 2022
Will Jones / @wjones127:
Thanks @boshek .
To provide an update: We have identified the issue now and my fix is currently being reviewed. It will likely be included in a 7.0.1 release.
You may be able to workaround the issue by setting
options(arrow.use_threads = TRUE), which will avoid this bug. (However, there are some cases where turning on threads on Windows cause other issues right now, hence why it's off by default on Windows.)asfimport commentedon Feb 14, 2022
Sam Albers / @boshek:
@wjones127 that's great! Does that catch instances where the join columns are partitions? I don't see any tests for that and the reprexes above suggest that might be relevant.
asfimport commentedon Feb 14, 2022
Weston Pace / @westonpace:
Issue resolved by pull request 12339
#12339
asfimport commentedon Feb 14, 2022
Weston Pace / @westonpace:
I went ahead and marked this closed with Will's change but feel free to reopen if either of you decide this doesn't cover all cases.
asfimport commentedon Feb 14, 2022
Will Jones / @wjones127:
Ah it actually does not. I don't think the problem is the partition columns per se; I think the fix i provided works for joining a dataset to an in-memory table, but not a dataset to a dataset. So need to add an additional test for that. Thanks for pointing that out! (y)
@westonpace With a dataset to dataset join we are getting a thread index of 2 now. I guess we have an IO thread per scanner, right? Probably need to modify our approach.
asfimport commentedon Feb 14, 2022
Weston Pace / @westonpace:
Yes, we would have an I/O thread per scanner in that case.
asfimport commentedon Feb 14, 2022
Weston Pace / @westonpace:
Well, we have 8 I/O threads (by default) and each scanner would use a different one of those 8.
asfimport commentedon Feb 15, 2022
Sam Albers / @boshek:
@wjones127 just to close the loop, your fix appears to have sorted out all the cases i outlined. Nice work! For the test, I was thinking something like this: