Uploaded image for project: 'Apache Arrow'
  1. Apache Arrow
  2. ARROW-10668

[R] Filtering does not work with .data pronoun

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 2.0.0
    • Fix Version/s: 3.0.0
    • Component/s: R

      Description

      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.

      Curious on thoughts/workarounds for this! Thank you!

      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)
      

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                jonkeane Jonathan Keane
                Reporter:
                sharlagelfand Sharla Gelfand
              • Votes:
                0 Vote for this issue
                Watchers:
                3 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:

                  Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0h
                  0h
                  Logged:
                  Time Spent - 1h 20m
                  1h 20m