[R] Support column renaming in col_select argument to file reading functions
- Dominant language
- C++
- Stars
- 17.1k
- Forks
- 4.3k
- Avg merge
- 3d 18h
- Merged PRs (30d)
- 91
Description
We should support the ability to rename columns when reading in data via the CSV/Parquet/Feather/JSON file readers.
We currently have an argument `col_select`, which allows users to choose which columns to read in, but renaming doesn't work.
To implement this, we'd need to check if any columns have been renamed by `col_select` and then updating the schema of the object being returned once the file has been read.
```r
library(readr)
library(arrow)
readr::read_csv(readr_example("mtcars.csv"), col_select = c(not_hp = hp))
#> # A tibble: 32 × 1
#> not_hp
#>
#> 1 110
#> 2 110
#> 3 93
#> 4 110
#> 5 175
#> 6 105
#> 7 245
#> 8 62
#> 9 95
#> 10 123
#> # … with 22 more rows
arrow::read_csv_arrow(readr_example("mtcars.csv"), col_select = c(not_hp = hp))
#> # A tibble: 32 × 1
#> hp
#>
#> 1 110
#> 2 110
#> 3 93
#> 4 110
#> 5 175
#> 6 105
#> 7 245
#> 8 62
#> 9 95
#> 10 123
#> # … with 22 more rows
```
**Reporter**: [Nicola Crane](https://issues.apache.org/jira/browse/ARROW-18049) / @thisisnic
**Note**: *This issue was originally created as [ARROW-18049](https://issues.apache.org/jira/browse/ARROW-18049). Please see the [migration documentation](https://github.com/apache/arrow/issues/14542) for further details.*
Contributor guide
Research direction
Start at the R file-reading entry points, especially read_csv_arrow(), and trace how col_select is applied for CSV, Parquet, Feather, and JSON readers. Verify the returned schema and column names using the examples in the issue; done means c(not_hp = hp) returns a column named not_hp across the supported readers.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- r
- Domain
- data
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100