Sparklyr fails when using a case_when
with external variables.
Working Example:
test <- copy_to(sc, tibble(column = c(1,2,3,4)))
test %>%
mutate(group = case_when(
column %in% c(1,2) ~ 'group 1',
column %in% c(3,4) ~ 'group 2'))
Fails with Error: Can't extract an environment from NULL
test <- copy_to(sc, tibble(column = c(1,2,3,4)))
group1_cols <- c(1,2)
group2_cols <- c(3,4)
test %>%
mutate(group = case_when(
column %in% group1_cols ~ 'group 1',
column %in% group2_cols ~ 'group 2'))