From 32482a416399383f536f21db5e295fc796977946 Mon Sep 17 00:00:00 2001 From: Stephanie Hazlitt Date: Mon, 29 Nov 2021 10:05:32 -0800 Subject: [PATCH 1/5] rm if_else type warning --- r/R/dplyr-functions.R | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/r/R/dplyr-functions.R b/r/R/dplyr-functions.R index 0ccc5734a7f..b1f8a65f93d 100644 --- a/r/R/dplyr-functions.R +++ b/r/R/dplyr-functions.R @@ -908,17 +908,6 @@ nse_funcs$if_else <- function(condition, true, false, missing = NULL) { )) } - # if_else doesn't yet support factors/dictionaries - # TODO: remove this after ARROW-13358 is merged - warn_types <- nse_funcs$is.factor(true) | nse_funcs$is.factor(false) - if (warn_types) { - warning( - "Dictionaries (in R: factors) are currently converted to strings (characters) ", - "in if_else and ifelse", - call. = FALSE - ) - } - build_expr("if_else", condition, true, false) } From f91d9079adb552b0d8b3272eb91754dcfe6d093a Mon Sep 17 00:00:00 2001 From: Stephanie Hazlitt Date: Mon, 29 Nov 2021 11:25:49 -0800 Subject: [PATCH 2/5] r warning from if_else test --- r/tests/testthat/test-dplyr-funcs-conditional.R | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/r/tests/testthat/test-dplyr-funcs-conditional.R b/r/tests/testthat/test-dplyr-funcs-conditional.R index 4e4346a7592..ddbd10c1d6f 100644 --- a/r/tests/testthat/test-dplyr-funcs-conditional.R +++ b/r/tests/testthat/test-dplyr-funcs-conditional.R @@ -116,8 +116,6 @@ test_that("if_else and ifelse", { tbl ) - # TODO: remove the mutate + warning after ARROW-13358 is merged and Arrow - # supports factors in if(_)else compare_dplyr_binding( .input %>% mutate( @@ -126,8 +124,7 @@ test_that("if_else and ifelse", { collect() %>% # This is a no-op on the Arrow side, but necessary to make the results equal mutate(y = as.character(y)), - tbl, - warning = "Dictionaries .* are currently converted to strings .* in if_else and ifelse" + tbl ) # detecting NA and NaN works just fine From a13b4a5e0662ca2879d1025abab5a5692627140a Mon Sep 17 00:00:00 2001 From: Stephanie Hazlitt Date: Mon, 29 Nov 2021 12:39:10 -0800 Subject: [PATCH 3/5] reset factor levels in test --- r/tests/testthat/test-dplyr-funcs-conditional.R | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/r/tests/testthat/test-dplyr-funcs-conditional.R b/r/tests/testthat/test-dplyr-funcs-conditional.R index ddbd10c1d6f..43c4a7f06f2 100644 --- a/r/tests/testthat/test-dplyr-funcs-conditional.R +++ b/r/tests/testthat/test-dplyr-funcs-conditional.R @@ -122,8 +122,10 @@ test_that("if_else and ifelse", { y = if_else(int > 5, fct, factor("a")) ) %>% collect() %>% - # This is a no-op on the Arrow side, but necessary to make the results equal - mutate(y = as.character(y)), + # Arrow coalesce() kernel does not preserve unused factor levels, + # so reset the levels of all the factor columns to make the test pass + # (ARROW-14649) + transmute(across(where(is.factor), ~ factor(.x, levels = c("a", "b", "c")))), tbl ) From a4d9378ec33829c64b93dff3c05e39c30c05011c Mon Sep 17 00:00:00 2001 From: Stephanie Hazlitt Date: Mon, 29 Nov 2021 12:46:53 -0800 Subject: [PATCH 4/5] Update r/tests/testthat/test-dplyr-funcs-conditional.R Co-authored-by: Neal Richardson --- r/tests/testthat/test-dplyr-funcs-conditional.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/r/tests/testthat/test-dplyr-funcs-conditional.R b/r/tests/testthat/test-dplyr-funcs-conditional.R index 43c4a7f06f2..a65b3a1dfce 100644 --- a/r/tests/testthat/test-dplyr-funcs-conditional.R +++ b/r/tests/testthat/test-dplyr-funcs-conditional.R @@ -122,7 +122,7 @@ test_that("if_else and ifelse", { y = if_else(int > 5, fct, factor("a")) ) %>% collect() %>% - # Arrow coalesce() kernel does not preserve unused factor levels, + # Arrow if_else() kernel does not preserve unused factor levels, # so reset the levels of all the factor columns to make the test pass # (ARROW-14649) transmute(across(where(is.factor), ~ factor(.x, levels = c("a", "b", "c")))), From ae404c933a779bd4516c5c40dedd4757d52303d5 Mon Sep 17 00:00:00 2001 From: Stephanie Hazlitt Date: Mon, 29 Nov 2021 14:39:32 -0800 Subject: [PATCH 5/5] Update r/tests/testthat/test-dplyr-funcs-conditional.R Co-authored-by: Ian Cook --- r/tests/testthat/test-dplyr-funcs-conditional.R | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/r/tests/testthat/test-dplyr-funcs-conditional.R b/r/tests/testthat/test-dplyr-funcs-conditional.R index a65b3a1dfce..a5e6ce6ea09 100644 --- a/r/tests/testthat/test-dplyr-funcs-conditional.R +++ b/r/tests/testthat/test-dplyr-funcs-conditional.R @@ -125,7 +125,10 @@ test_that("if_else and ifelse", { # Arrow if_else() kernel does not preserve unused factor levels, # so reset the levels of all the factor columns to make the test pass # (ARROW-14649) - transmute(across(where(is.factor), ~ factor(.x, levels = c("a", "b", "c")))), + transmute(across( + where(is.factor), + ~ factor(.x, levels = c("a", "b", "c", "d", "g", "h", "i", "j")) + )), tbl )