apache / apache/arrow

[R] Removing files after reading them in R

Open
#32,497 2 comments 0 reactions 0 assignees View on GitHub
Component: R Type: bug
Dominant language
C++
Stars
17.1k
Forks
4.3k
Avg merge
3d 18h
Merged PRs (30d)
91

Description

In R it's not possible to delete the files eventhough the dataframe is cleared from the R environment. 

```r

write.csv(mtcars, file = "mtcars.csv", quote = FALSE, row.names = FALSE)
df <- arrow::to_duckdb(arrow::open_dataset("mtcars.csv", format = "csv", delimiter = ","))

df <- df %>% select(c("mpg", "disp", "drat", "wt")) %>% collect()

## Do some checks on df.

rm(df)
file.remove("mtcars.csv")
```

The `file.remove` leads to a Permission Denied error eventhough the dataframe is cleared from the R environment. 

**Reporter**: [Wytze Gelderloos](https://issues.apache.org/jira/browse/ARROW-17208)

**Note**: *This issue was originally created as [ARROW-17208](https://issues.apache.org/jira/browse/ARROW-17208). Please see the [migration documentation](https://github.com/apache/arrow/issues/14542) for further details.*

Contributor guide

Open the contributing guide

Research direction

Start by running the R reproduction in the issue and confirm that file.remove("mtcars.csv") fails after rm(df). Trace the Arrow R dataset and collect path to identify which object still holds the file, then verify that the file can be removed after the dataframe is cleared without a permission error.

Written by the indexing model from the issue text.

Assessment

Tech stack
r
Domain
data-engineering
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.