Sharla Gelfand created ARROW-10668:
--------------------------------------
Summary: [R] Filtering does not work with .data pronoun
Key: ARROW-10668
URL: https://issues.apache.org/jira/browse/ARROW-10668
Project: Apache Arrow
Issue Type: Bug
Components: R
Affects Versions: 2.0.0
Reporter: Sharla Gelfand
Filtering while using the `.data` pronoun does not work properly on arrow
datasets - presumably because `.data` is meaningful for something else in
arrow? `.data` doesn't always need to be used when using dplyr verbs
interactively, but it is pretty much a requirement when writing packages that
use the verbs, to [avoid an R CMD check
note.|https://rlang.r-lib.org/reference/tidyeval-data.html]
Curious on thoughts/workarounds for this! Thank you!
{code:r}
library(dplyr)
library(arrow)
# Filtering using .data pronoun works on regular objects
mtcars %>%
filter(.data$cyl == 6)
#> mpg cyl disp hp drat wt qsec vs am gear carb
#> Mazda RX4 21.0 6 160.0 110 3.90 2.620 16.46 0 1 4 4
#> Mazda RX4 Wag 21.0 6 160.0 110 3.90 2.875 17.02 0 1 4 4
#> Hornet 4 Drive 21.4 6 258.0 110 3.08 3.215 19.44 1 0 3 1
#> Valiant 18.1 6 225.0 105 2.76 3.460 20.22 1 0 3 1
#> Merc 280 19.2 6 167.6 123 3.92 3.440 18.30 1 0 4 4
#> Merc 280C 17.8 6 167.6 123 3.92 3.440 18.90 1 0 4 4
#> Ferrari Dino 19.7 6 145.0 175 3.62 2.770 15.50 0 1 5 6
# But it does not seem to on arrow data sets
tmp <- tempfile()
write_dataset(mtcars, tmp, format = "parquet")
mtcars_arrow <- open_dataset(tmp)
# Filtering works fine without the pronoun
mtcars_arrow %>%
filter(cyl == 6) %>%
collect()
#> mpg cyl disp hp drat wt qsec vs am gear carb
#> 1 21.0 6 160.0 110 3.90 2.620 16.46 0 1 4 4
#> 2 21.0 6 160.0 110 3.90 2.875 17.02 0 1 4 4
#> 3 21.4 6 258.0 110 3.08 3.215 19.44 1 0 3 1
#> 4 18.1 6 225.0 105 2.76 3.460 20.22 1 0 3 1
#> 5 19.2 6 167.6 123 3.92 3.440 18.30 1 0 4 4
#> 6 17.8 6 167.6 123 3.92 3.440 18.90 1 0 4 4
#> 7 19.7 6 145.0 175 3.62 2.770 15.50 0 1 5 6
# Using the .data pronoun, does not return any data
mtcars_arrow %>%
filter(.data$cyl == 6) %>%
collect()
#> [1] mpg cyl disp hp drat wt qsec vs am gear carb
#> <0 rows> (or 0-length row.names)
{code}
--
This message was sent by Atlassian Jira
(v8.3.4#803005)