Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ARROW-13749: [Doc][Cookbook] Work with functions from other packages via dplyr bindings - R #95

Merged
merged 2 commits into from Nov 3, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
40 changes: 40 additions & 0 deletions r/content/tables.Rmd
Expand Up @@ -146,6 +146,13 @@ If you find any base R or tidyverse functions which you would like to see a
mapping of in arrow, please
[open an issue on the project JIRA](https://issues.apache.org/jira/projects/ARROW/issues).

The following packages (amongst some from others) have had many function
bindings/mappings written in arrow:

* [lubridate](https://lubridate.tidyverse.org/)
* [stringr](https://stringr.tidyverse.org/)
* [dplyr](https://dplyr.tidyverse.org/)

If you try to call a function which does not have arrow mapping, the data will
be pulled back into R, and you will see a warning message.

Expand All @@ -171,6 +178,39 @@ test_that("dplyr_func_warning", {

})
```

It should be noted that to work with functions which do have mappings, you must
refer to them by
their function names. If you use the `package::function()` syntax, this will
result in a warning about the data being pulled back into R before the output is
calculated.

```{r, dplyr_str_to_lower_r, warning=TRUE}
Table$create(starwars) %>%
select(name) %>%
mutate(name_lower = stringr::str_to_lower(name)) %>%
head() %>%
collect()
```

```{r, test_dplyr_str_to_lower_r, opts.label = "test"}

test_that("dplyr_str_to_lower_r", {

expect_warning(
Table$create(starwars) %>%
select(name) %>%
mutate(name_lower = stringr::str_to_lower(name)) %>%
head() %>%
collect(),
"Expression stringr::str_to_lower(name) not supported in Arrow; pulling data into R",
fixed = TRUE
)

})

```

## Use arrow functions in dplyr verbs in arrow

You want to use a function which is implemented in Arrow's C++ library but either:
Expand Down