nealrichardson commented on a change in pull request #9798:
URL: https://github.com/apache/arrow/pull/9798#discussion_r602512378



##########
File path: r/tests/testthat/test-dplyr.R
##########
@@ -369,3 +384,46 @@ test_that("tail", {
       group_by(int)
     )
 })
+
+test_that("relocate", {
+  df <- tibble(a = 1, b = 1, c = 1, d = "a", e = "a", f = "a")
+  expect_dplyr_equal(
+    input %>% relocate(f) %>% collect(),
+    df,
+  )
+  expect_dplyr_equal(
+    input %>% relocate(a, .after = c) %>% collect(),
+    df,
+  )
+  expect_dplyr_equal(
+    input %>% relocate(f, .before = b) %>% collect(),
+    df,
+  )
+  expect_dplyr_equal(
+    input %>% relocate(a, .after = last_col()) %>% collect(),
+    df,
+  )
+  expect_dplyr_equal(
+    input %>% relocate(ff = f) %>% collect(),
+    df,
+  )
+})
+
+test_that("relocate with selection helpers", {
+  expect_dplyr_equal(
+    input %>% relocate(any_of(c("a", "e", "i", "o", "u"))) %>% collect(),
+    df
+  )
+  expect_error(
+    df %>% Table$create() %>% relocate(where(is.character)),

Review comment:
       What is the failure mode without `check_select_helpers()`?
   
   Likewise with select/rename: how do they fail differently without checking? 
(If we're adding the check, we should add tests too)
   
   How does dbplyr et al. handle these? Surely you would have the same problem 
of `select(where(is.factor))` any time you're dealing with a non-data.frame 
backend.

##########
File path: r/tests/testthat/test-dplyr.R
##########
@@ -156,6 +156,21 @@ test_that("select/rename", {
   )
 })
 
+test_that("select/rename with selection helpers", {
+
+  # TODO: add some passing tests here
+
+  expect_error(
+    expect_dplyr_equal(
+      input %>%
+        select(where(is.numeric)) %>%

Review comment:
       is "where" the problem or is it "is.numeric"?

##########
File path: r/R/util.R
##########
@@ -45,3 +45,37 @@ is_list_of <- function(object, class) {
 }
 
 empty_named_list <- function() structure(list(), .Names = character(0))
+

Review comment:
       This seems like the kind of stuff that would be in `rlang`. Is it not?

##########
File path: r/R/dplyr.R
##########
@@ -216,6 +215,52 @@ column_select <- function(.data, ..., .FUN = vars_select) {
   .data
 }
 
+relocate.arrow_dplyr_query <- function(.data, ..., .before = NULL, .after = 
NULL) {

Review comment:
       Ok, add a comment here referencing the original version, and perhaps 
also link to https://github.com/tidyverse/dplyr/issues/5829 in the comment




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to